Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
L4d2 Plugin Simplification #2650
While working on a plugin for a different game I noticed quite a bit of overlap between the Windows and Linux versions of the l4d2 plugin.
I've separated the constants from the program logic, and have combined the two files. This should massively ease future maintenance, and allow for easier updating should those constants change.
Note: I've compiled this on Linux, but can't test it. I do not have a Windows build system at this time.
Glad to contribute. How does it break wine?
l4d2.pro only had the Windows file on win32, and only had the Linux file on linux. I would love to build all the Windows plugins on Linux, but that currently doesn't happen.
What are your thoughts on using a constants section instead of having them in the code itself? It's what the wow plugin does, and seems a bit more readable than what the wiki currently recommends.
It doesn't break wine per se. but the process we had in mind for wine plugins would be that Windows plugins have one build dir, and Linux plugins had another one.
For l4d2, this would probably be 'l4d2' for Windows, and 'l4d2_linux' for Linux.
Why separte dirs? Well, qmake can only produce one binary per directory, since a directory can only contain one .pro file. (At least when used with qmake SUBDIRS...)
The idea we had in mind would be that all Windows plugin would be built on Linux, but named something like 'libmumble_paplugin_win32_$TARGET.so'.
So, to be able to accomplish this, we'd need separate dirs for the Windows/wine version vs. the Linux version.
But -- that isn't even the case right now for the l4d2 plugin. Both Windows and Linux currently live in the same directory, so I'm fine with this change if @davidebeatrici thinks it improves readability/maintainability.
We can think about Wine later.
We could keep the folder l4d2 and create two subfolders inside it: win32 and linux.
static procptr32_t steamclient, server, engine; // Variables to contain modules addresses (...) const procptr32_t serverid_offset = 0x1216CA5; const procptr32_t player_offset = 0xF340E4; const procptr32_t playerid_offset = 0xA62C60; (...) peekProc(steamclient + serverid_offset, serverid) && // Unique server Steam ID. (...) peekProc(server + player_offset, player) && // Player nickname. peekProc(engine + playerid_offset, playerid); // Unique player Steam ID. (...) steamclient = getModuleAddr(steamclient_name); // Retrieve "steamclient_name" module's memory address (...) server = getModuleAddr(server_name); // Retrieve "server_name" module's memory address (...) engine = getModuleAddr(engine_name); // Retrieve "engine_name" module's memory address (...)