Skip to content

Instantly share code, notes, and snippets.

View Swyter's full-sized avatar
💭
¯\_(ツ)_/¯

Swyter Swyter

💭
¯\_(ツ)_/¯
View GitHub Profile
@Swyter
Swyter / pc-port-best-practices.md
Last active July 8, 2022 03:28
PC game port best practices
  • Always use scancodes for keyboard game input to make WASD work even under DVORAK or AZERTY layouts; you care about the key position, not the meaning.

    • Use keycodes to retrieve the actual key meaning/value when you need actual text input.
  • Support paths bigger than 256 characters (MAX_PATH), this should no longer be a limitation. Launch your game from a folder or symlink with hundreds of characters; this can be combined with the next point.

  • Try your game with a special username/user account that has international characters and spaces, like Ñame áôeÓ®他の詩っステム 元バ to ensure you are handling Unicode paths correctly. This is especially tricky on Windows, where you will have to wrap fopen() with the UTF-16 version because the normal version does not understand UTF-8.

    • Very often players with non-English names won't be able to save under AppData or their home directory otherwise.
  • On Windows you should store your savegames under the special %USERPROFILE%\Saved Games folder, use a dynamica

[font=bell mt,serif][SIZE=27px]Create your own Mount&Blade Fonts like a pro. [I]Feedback appreciated[/I].[/SIZE][/font]
This is going to be short and sweet. Stuff you are going to need:
[+] [I]Angelcode's BMFont[/I] which you can obtain [URL='http://www.angelcode.com/products/bmfont/']from here[/URL].
[+] A relatively decent web browser pointed to [CODE]http://swyter.bitbucket.io[/CODE].
[+] A bitmap editor like [I]Photoshop[/I] or [I]Gimp[/I], together with a DDS plugin for opening and saving textures with mipmaps is a must.
[+] Good reading skills and over-the-top attention span.
[font=bell mt,serif][SIZE=24px]— [I]Step one[/I] — Create your brand new bitmap font[/SIZE][/font]
@Swyter
Swyter / terraingen-rescued-lib-perlin.cpp
Last active April 26, 2021 19:54
cmpxchg8b's TerrainGen code; generates a scene mesh from their respective terrain code, just like Mount&Blade Warband does. Recovered from a corrupted disk, these aren't the original filenames.
#include "Perlin.h"
#include "Utils.h"
#include <cmath>
unsigned char g_perlinPermutationTable[256] =
{
198, 12, 146, 95, 44, 18, 240, 28, 151, 32, 45, 20, 30, 23, 141, 248,
168, 254, 178, 85, 92, 216, 236, 175, 47, 88, 67, 136, 234, 1, 72, 106,
79, 220, 24, 171, 26, 224, 128, 137, 223, 16, 105, 195, 231, 183, 29, 132,
241, 122, 252, 135, 5, 181, 130, 213, 49, 204, 70, 176, 144, 35, 64, 104,
@Swyter
Swyter / gist:5463317d93576f055f2143e277750176
Created July 18, 2020 06:58
mount-read-write-ntfs-3g-macos.sh
diskutil unmount /dev/disk2s4
sudo /usr/local/bin/ntfs-3g /dev/disk2s4 /Volumes/ntfs -olocal -oallow_other -o auto_xattr -o remove_hiberfile
> ntfs 3g not showing files finder -> -o auto_xattr
https://github.com/osxfuse/osxfuse/issues/574#issuecomment-541309529
> The disk contains an unclean file system mac -> -o remove_hiberfile
https://askubuntu.com/a/145904
@Swyter
Swyter / __v3_bluetooth.h
Last active July 4, 2020 17:08
Fixed version of the cloned Chinese CSR Bluetooth dongle handling for the Linux Kernel 5.7.4 -- https://bugzilla.kernel.org/show_bug.cgi?id=60824
/*
BlueZ - Bluetooth protocol stack for Linux
Copyright (C) 2000-2001 Qualcomm Incorporated
Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation;
https://discord.com/channels/492783428635328532/492787561769599008/714065506617000006
https://cdn.discordapp.com/attachments/492787561769599008/714065506096644136/TLD_goes_black_report.rtf
Thread 0 Crashed:: MainThrd    Dispatch queue: com.apple.main-thread
0      libsystem_c.dylib          0x00007fff6d316a5d flockfile + 18
1      libsystem_c.dylib          0x00007fff6d31f298 vfprintf_l + 28
2      libsystem_c.dylib          0x00007fff6d31815d fprintf + 160
0x100000000 + 9558992 = 100921fdb / 0x10d537000 + 9576411 3      taleworlds.Mount-and-Blade 0x000000010de58fdb 0x10d537000 + 9576411
0x100000000 + 10012602 = 10098c7ba / 0x10d537000 + 10012602 4      taleworlds.Mount-and-Blade 0x000000010dec37ba 0x10d537000 + 10012602
0x100000000 + 9558992 = 10091dbd0 /
06 CARTRIDGE
16 IS
17 FLYER/PROMO
| 33 DVD-9 / WIIU disc (SL)
OPTICAL | 34 DVD-5 / WII disc (SL)
| 35 BD-25
| 36 BD-50
44 BOX/PACKAGE
50 INSTALL INSTRUCTIONS SHEET/MANUAL
@Swyter
Swyter / mb.fx
Last active April 5, 2020 06:22
Native, original HLSL shader file for Mount&Blade 1.011, found in the root folder of the enhanced version - Copyright (C) 2009 TaleWorlds Entertainment İkisoft - https://www.moddb.com/games/mount-blade/downloads/mountblade-1011-fall-2009-enhanced-version
#define NUM_LIGHTS 10
#define NUM_SIMUL_LIGHTS 4
#define NUM_WORLD_MATRICES 32
#define LIGHT_TYPE_NONE 0
#define LIGHT_TYPE_POINT 1
#define LIGHT_TYPE_DIRECTIONAL 2
#define LIGHT_NUM_TYPES 3
#define PCF_NONE 0
SORTED LANG ID LOAD SCREEN SUBFILE DEFAULT FONT HT_File_Fonts1 SUBFILE
not hardcoded; XLS hardcoded hardcoded on level init
LANGUAGE_ENGLISH_US HT_SubFile_File10 HT_Font_Default HT_SubFile_File01
LANGUAGE_ENGLISH_UK HT_SubFile_File10 HT_Font_Default_UK HT_SubFile_File02
LANGUAGE_FRENCH HT_SubFile_File16 HT_Font_Default_FRENCH HT_SubFile_File03
LANGUAGE_GERMAN HT_SubFile_File15 HT_Font_Default_GERMAN HT_SubFile_File04
@Swyter
Swyter / 1—Download and first steps.txt
Last active August 17, 2019 00:19
Authoring Tools Starting Guide on Steam Community - Backup
First things first, download the free DLC with the required tools and data from your Steam client.
(Ensure that you own the game first and that you have it installed, you will need around 7.2 GB of total free space, even the actual download size is much more manageable; at ~1.9 GB)
Keep in mind that the DLC doesn't get installed by default due to its size, you will have to click on the "[i]Install[/i]" checkbox in the DLC section of your Steam client, right under achievements. Like this:
[previewimg=11489374;sizeOriginal,floatLeft;sphinx-authoringtools-download.PNG][/previewimg]
The Steam client should immediately start to download, it may take a while.