also write private list from games.xml

- also write private list from games.xml, prevent sneaky mistakes
- rewrite some things a better way
- close files
This commit is contained in:
Thomas Debesse 2018-03-31 17:07:59 +02:00
parent 1059e31378
commit ed2f2d8255
7 changed files with 145 additions and 152 deletions

View File

@ -506,7 +506,9 @@ add_custom_command (
DEPENDS gamesxml2c)
# Define games.c filename for including in src/game.c
add_definitions (-DGAMES_INCLUDE="${CMAKE_BINARY_DIR}/games.c")
add_definitions (-DGAMES_C_INCLUDE="${CMAKE_BINARY_DIR}/games.c")
add_definitions (-DGAMES_H_INCLUDE="${CMAKE_BINARY_DIR}/games.h")
add_definitions (-DICONS_C_INCLUDE="${CMAKE_BINARY_DIR}/icons.c")
# Make src/game.c depend on games.c so that src/game.c is rebuilt when games.c changes,
# this must be manually specified due to the include name being a define

View File

@ -26,7 +26,7 @@
#include <gtk/gtk.h>
#include <glib.h>
#include "games.h"
#include GAMES_H_INCLUDE
// max 0x8000, server->flags is unsigned
enum server_flags {

View File

@ -154,53 +154,7 @@ struct unreal_private
const char* suffix;
};
static struct quake_private alienarena_private;
static struct quake_private cod_private;
static struct quake_private coduo_private;
static struct quake_private cod2_private;
static struct quake_private cod4_private;
static struct quake_private dday_private;
static struct quake_private doom3_private;
static struct quake_private etl_private;
static struct quake_private etqw_private;
static struct quake_private hl_private;
static struct quake_private iourt_private;
static struct quake_private jk2_private;
static struct quake_private jk3_private;
static struct quake_private mohaa_private;
static struct quake_private nexuiz_private;
static struct quake_private openarena_private;
static struct quake_private q1_private;
static struct quake_private q2_private;
static struct quake_private q3_private;
static struct quake_private q3rally_private;
static struct quake_private quake4_private;
static struct quake_private quetoo_private;
static struct quake_private qw_private;
static struct quake_private reaction_private;
static struct quake_private smokinguns_private;
static struct quake_private teeworlds_private;
static struct quake_private tremfusion_private;
static struct quake_private tremulousgpp_private;
static struct quake_private tremulous_private;
static struct quake_private turtlearena_private;
static struct quake_private unvanquished_private;
static struct quake_private warsow_private;
static struct quake_private wolfet_private;
static struct quake_private wolf_private;
static struct quake_private wop_private;
static struct quake_private xonotic_private;
static struct quake_private zeq2lite_private;
static struct unreal_private aao_private = { NULL, ".aao" };
static struct unreal_private postal2_private = { NULL, ".fuk" };
static struct unreal_private rune_private = { NULL, ".run" };
static struct unreal_private ut2004_private = { NULL, ".ut2" };
static struct unreal_private ut2_private = { NULL, ".ut2" };
static struct unreal_private ut_private = { NULL, ".unr" };
#include GAMES_INCLUDE
#include GAMES_C_INCLUDE
struct gsname2type_s
{

View File

@ -135,7 +135,9 @@ struct game {
char *game_cfg;
GData *games_data;
GSList *custom_args;
/** game specific private data */
// char *private_suffix;
void *pd;
};

View File

@ -31,6 +31,7 @@
<update_prefs/>
<default_home/>
<main_mod/>
<private_suffix/>
<pd/>
</game>
<game>
@ -48,7 +49,6 @@
<prefs_load>q2_prefs_load</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>arena</main_mod>
<pd>alienarena_private</pd>
</game>
<game>
<base>UN_SERVER</base>
@ -61,7 +61,7 @@
<qstat_option>-ams</qstat_option>
<icon>aao.xpm</icon>
<command>armyops</command>
<pd>aao_private</pd>
<private_suffix>.aao</private_suffix>
</game>
<game>
<type>BF1942_SERVER</type>
@ -93,7 +93,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>main</main_mod>
<pd>cod_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -112,7 +111,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>uo</main_mod>
<pd>coduo_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -131,7 +129,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>main</main_mod>
<pd>cod2_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -150,7 +147,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>main</main_mod>
<pd>cod4_private</pd>
</game>
<game>
<base>Q2_SERVER</base>
@ -160,7 +156,6 @@
<icon>dday.xpm</icon>
<command>DDaynormandy</command>
<main_mod>dday</main_mod>
<pd>dday_private</pd>
</game>
<game>
<type>DESCENT3_SERVER</type>
@ -206,7 +201,6 @@
<main_mod>base</main_mod>
<attributes>+net_clientRemoteConsolePassword</attributes>
<attributes>+rconpassword</attributes>
<pd>doom3_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -223,7 +217,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>etmain</main_mod>
<pd>etl_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -248,7 +241,6 @@
<main_mod>base</main_mod>
<attributes>+net_clientRemoteConsolePassword</attributes>
<attributes>+rconpassword</attributes>
<pd>etqw_private</pd>
</game>
<game>
<type>HL_SERVER_OLD</type>
@ -268,7 +260,6 @@
<has_map>quake_has_map</has_map>
<arch_identifier>sv_os</arch_identifier>
<identify_os>identify_os</identify_os>
<pd>hl_private</pd>
</game>
<game>
<type>HL_SERVER</type>
@ -288,7 +279,6 @@
<has_map>quake_has_map</has_map>
<arch_identifier>sv_os</arch_identifier>
<identify_os>identify_os</identify_os>
<pd>hl_private</pd>
</game>
<game>
<type>HL2_SERVER</type>
@ -365,7 +355,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>base</main_mod>
<pd>jk2_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -387,7 +376,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>base</main_mod>
<pd>jk3_private</pd>
</game>
<game>
<type>KP_SERVER</type>
@ -418,7 +406,6 @@
<command>mohaa</command>
<default_home>~/.mohaa</default_home>
<main_mod>main</main_mod>
<pd>mohaa_private</pd>
</game>
<game>
<type>NETP_SERVER</type>
@ -452,7 +439,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>data</main_mod>
<pd>nexuiz_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -471,7 +457,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>baseq3</main_mod>
<pd>openarena_private</pd>
</game>
<game>
<type>OTTD_SERVER</type>
@ -500,7 +485,7 @@
<icon>postal2.xpm</icon>
<command>postal2mpdemo</command>
<command>postal2mp</command>
<pd>postal2_private</pd>
<private_suffix>.fuk</private_suffix>
</game>
<game>
<base>Q3_SERVER</base>
@ -519,7 +504,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>baseq3</main_mod>
<pd>q3rally_private</pd>
</game>
<game>
<type>Q1_SERVER</type>
@ -546,7 +530,6 @@
<prefs_load>q1_prefs_load</prefs_load>
<update_prefs>q1_update_prefs</update_prefs>
<main_mod>id1</main_mod>
<pd>q1_private</pd>
</game>
<game>
<type>QW_SERVER</type>
@ -577,7 +560,6 @@
<update_prefs>qw_update_prefs</update_prefs>
<main_mod>qw</main_mod>
<main_mod>id1</main_mod>
<pd>qw_private</pd>
</game>
<game>
<type>Q2_SERVER</type>
@ -607,7 +589,6 @@
<prefs_load>q2_prefs_load</prefs_load>
<update_prefs>q2_update_prefs</update_prefs>
<main_mod>baseq2</main_mod>
<pd>q2_private</pd>
</game>
<game>
<type>Q3_SERVER</type>
@ -640,7 +621,6 @@
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>demoq3</main_mod>
<main_mod>baseq3</main_mod>
<pd>q3_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -669,7 +649,6 @@
<main_mod>q4base</main_mod>
<attributes>+net_clientRemoteConsolePassword</attributes>
<attributes>+rconpassword</attributes>
<pd>quake4_private</pd>
</game>
<game>
<base>Q2_SERVER</base>
@ -685,7 +664,6 @@
<command>quetoo</command>
<default_home>~/.quetoo</default_home>
<main_mod>default</main_mod>
<pd>quetoo_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -704,7 +682,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>rq3</main_mod>
<pd>reaction_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -723,7 +700,6 @@
<main_mod>demomain</main_mod>
<main_mod>main</main_mod>
<main_mod>wolfmp</main_mod>
<pd>wolf_private</pd>
</game>
<game>
<base>UN_SERVER</base>
@ -732,7 +708,7 @@
<id>RUNESRV</id>
<icon>rune.xpm</icon>
<command>rune</command>
<pd>rune_private</pd>
<private_suffix>.run</private_suffix>
</game>
<game>
<type>SAS_SERVER</type>
@ -800,7 +776,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>smokinguns</main_mod>
<pd>smokinguns_private</pd>
</game>
<game>
<type>SFS_SERVER</type>
@ -849,7 +824,6 @@
<exec_client>teeworlds_exec</exec_client>
<command>teeworlds</command>
<default_home>~/.teeworlds</default_home>
<pd>teeworlds_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -870,7 +844,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>base</main_mod>
<pd>tremfusion_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -892,7 +865,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>base</main_mod>
<pd>tremulous_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -913,7 +885,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>base</main_mod>
<pd>tremulousgpp_private</pd>
</game>
<game>
<type>T2_SERVER</type>
@ -953,7 +924,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>baseturtle</main_mod>
<pd>turtlearena_private</pd>
</game>
<game>
<type>UN_SERVER</type>
@ -970,7 +940,7 @@
<init_maps>unreal_init_maps</init_maps>
<has_map>unreal_has_map</has_map>
<command>ut</command>
<pd>ut_private</pd>
<private_suffix>.unr</private_suffix>
</game>
<game>
<base>UN_SERVER</base>
@ -984,7 +954,7 @@
<command>ut2003_demo</command>
<command>ut2003</command>
<default_home>~/.ut2003</default_home>
<pd>ut2_private</pd>
<private_suffix>.ut2</private_suffix>
</game>
<game>
<base>UN_SERVER</base>
@ -1002,7 +972,7 @@
<cmd_or_dir_changed>ut2004_cmd_or_dir_changed</cmd_or_dir_changed>
<update_prefs>ut2004_update_prefs</update_prefs>
<default_home>~/.ut2004</default_home>
<pd>ut2004_private</pd>
<private_suffix>.ut2</private_suffix>
</game>
<game>
<base>Q3_SERVER</base>
@ -1024,7 +994,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>pkg</main_mod>
<pd>unvanquished_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -1045,7 +1014,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>q3ut4</main_mod>
<pd>iourt_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -1081,7 +1049,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>basewsw</main_mod>
<pd>warsow_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -1098,7 +1065,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>etmain</main_mod>
<pd>wolfet_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -1117,7 +1083,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>wop</main_mod>
<pd>wop_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -1138,7 +1103,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs_common</update_prefs>
<main_mod>data</main_mod>
<pd>xonotic_private</pd>
</game>
<game>
<base>Q3_SERVER</base>
@ -1157,7 +1121,6 @@
<prefs_load>q3_prefs_load_common</prefs_load>
<update_prefs>q3_update_prefs</update_prefs>
<main_mod>ZEQ2</main_mod>
<pd>zeq2lite_private</pd>
</game>
<game>
<type>GPS_SERVER</type>

View File

@ -17,13 +17,18 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#define MALLOC(var, type) var = malloc(sizeof(type)); if(!var) abort(); memset(var, 0, sizeof(type));
#define WARNING_HEADER "// DO NOT EDIT THIS FILE, AUTOMATICALLY GENERATED"
typedef enum
{
Tag_0,
@ -57,6 +62,7 @@ typedef enum
TAG_prefs_load,
TAG_update_prefs,
TAG_default_home,
TAG_private_suffix,
TAG_pd,
TAG_end_basic = TAG_pd,
@ -113,7 +119,7 @@ static void tags_init() {
add_tag(TAG_qstat_str, Tag_do_inherit, Tag_type_string, (xmlChar*) "qstat_str");
add_tag(TAG_qstat_option, Tag_do_inherit, Tag_type_string, (xmlChar*) "qstat_option");
add_tag(TAG_qstat_master_option, Tag_do_inherit, Tag_type_string, (xmlChar*) "qstat_master_option");
add_tag(TAG_icon, Tag_do_inherit, Tag_type_string, (xmlChar*) "icon");
add_tag(TAG_icon, Tag_do_inherit, Tag_type_string, (xmlChar*) "icon");
add_tag(TAG_parse_player, Tag_do_inherit, Tag_type_literal, (xmlChar*) "parse_player");
add_tag(TAG_parse_server, Tag_do_inherit, Tag_type_literal, (xmlChar*) "parse_server");
add_tag(TAG_analyze_serverinfo, Tag_do_inherit, Tag_type_literal, (xmlChar*) "analyze_serverinfo");
@ -132,6 +138,7 @@ static void tags_init() {
add_tag(TAG_prefs_load, Tag_no_inherit, Tag_type_literal, (xmlChar*) "prefs_load");
add_tag(TAG_update_prefs, Tag_no_inherit, Tag_type_literal, (xmlChar*) "update_prefs");
add_tag(TAG_default_home, Tag_no_inherit, Tag_type_string, (xmlChar*) "default_home");
add_tag(TAG_private_suffix, Tag_no_inherit, Tag_type_string, (xmlChar*) "private_suffix");
add_tag(TAG_pd, Tag_no_inherit, Tag_type_address, (xmlChar*) "pd");
add_tag(TAG_data, Tag_no_inherit, Tag_type_literal, (xmlChar*) "data");
add_tag(TAG_main_mod, Tag_no_inherit, Tag_type_string, (xmlChar*) "main_mod");
@ -142,22 +149,25 @@ static void tags_init() {
}
const xmlChar* tag_name(GameTag tag) {
if (tag < TAG_start_basic || tag >= TAG_invalid)
if (tag < TAG_start_basic || tag >= TAG_invalid) {
return NULL;
}
return tags[tag].name;
}
TagInherit tag_inherit(GameTag tag) {
if (tag < TAG_start_basic || tag >= TAG_invalid)
if (tag < TAG_start_basic || tag >= TAG_invalid) {
return 0;
}
return tags[tag].inherit;
}
TagType tag_type(GameTag tag) {
if (tag < TAG_start_basic || tag >= TAG_invalid)
if (tag < TAG_start_basic || tag >= TAG_invalid) {
return 0;
}
return tags[tag].type;
}
@ -197,8 +207,6 @@ GameTag getGameTag(const xmlChar* str) {
return tag;
}
#define MALLOC(var, type) var = malloc(sizeof(type)); if(!var) abort(); memset(var, 0, sizeof(type));
RawGame* parseGame(xmlDocPtr doc, xmlNodePtr node) {
GameTag tag;
xmlChar* val = NULL;
@ -207,7 +215,9 @@ RawGame* parseGame(xmlDocPtr doc, xmlNodePtr node) {
MALLOC(rawgame, RawGame);
for (node = node->xmlChildrenNode; node; node = node->next) {
if (node->type != XML_ELEMENT_NODE) continue;
if (node->type != XML_ELEMENT_NODE) {
continue;
}
tag = getGameTag(node->name);
@ -244,7 +254,9 @@ GameList* parseGames(const char* filename) {
GameList* list = NULL;
doc = xmlParseFile(filename);
if (doc == NULL) return(NULL);
if (doc == NULL) {
return(NULL);
}
node = xmlDocGetRootElement(doc);
if (node == NULL) {
@ -276,30 +288,38 @@ GameList* parseGames(const char* filename) {
return list;
}
void printGame(FILE* cfile, RawGame* rg, RawGame* template) {
void printGame(FILE* games_c_file, RawGame* rg, RawGame* template) {
GameTag tag;
fputs("\t{\n", cfile);
fputs("\t{\n", games_c_file);
for (tag = TAG_start_basic; tag <= TAG_end_basic; ++tag) {
xmlChar* val = rg->basic[tag];
if (!val && rg->base && tag_inherit(tag))
if (tag == TAG_private_suffix) {
continue;
}
if (!val && rg->base && tag_inherit(tag)) {
val = rg->base->basic[tag];
}
if (!val)
if (!val) {
val = template->basic[tag];
}
if (!val || !xmlStrcmp(val, (xmlChar*) "NULL")) continue;
if (!val || !xmlStrcmp(val, (xmlChar*) "NULL")) {
continue;
}
switch(tag_type(tag)) {
case Tag_type_string:
fprintf(cfile, "\t\t.%-20s = \"%s\",\n", tag_name(tag), val);
fprintf(games_c_file, "\t\t.%-20s = \"%s\",\n", tag_name(tag), val);
break;
case Tag_type_address:
fprintf(cfile, "\t\t.%-20s = &%s,\n", tag_name(tag), val);
fprintf(games_c_file, "\t\t.%-20s = &%s,\n", tag_name(tag), val);
break;
case Tag_type_literal:
fprintf(cfile, "\t\t.%-20s = %s,\n", tag_name(tag), val);
fprintf(games_c_file, "\t\t.%-20s = %s,\n", tag_name(tag), val);
break;
case Tag_type_invalid:
break;
@ -309,18 +329,22 @@ void printGame(FILE* cfile, RawGame* rg, RawGame* template) {
for (tag = TAG_start_multi; tag <= TAG_end_multi; ++tag) {
struct MultiTag* m = rg->multi[tag - TAG_start_multi];
if (!m && rg->base && tag_inherit(tag))
if (!m && rg->base && tag_inherit(tag)) {
m = rg->base->multi[tag - TAG_start_multi];
}
if (!m)
if (!m) {
m = template->multi[tag - TAG_start_multi];
}
if (!m || !m->val || !xmlStrcmp(m->val, (xmlChar*) "NULL")) continue;
if (!m || !m->val || !xmlStrcmp(m->val, (xmlChar*) "NULL")) {
continue;
}
fprintf(cfile, "\t\t.%-20s = stringlist%03u,\n", tag_name(tag), rg->num_multitags++);
fprintf(games_c_file, "\t\t.%-20s = stringlist%03u,\n", tag_name(tag), rg->num_multitags++);
}
fputs("\t},\n", cfile);
fputs("\t},\n", games_c_file);
}
int main (int argc, char* argv[]) {
@ -328,22 +352,23 @@ int main (int argc, char* argv[]) {
GameList* ptr = NULL;
GameList* next = NULL;
RawGame* template = NULL;
unsigned i = 0, type_count;
xmlChar *buf, *c;
unsigned i;
if (argc < 3) return 1;
FILE* cfile = fopen(argv[2], "w");;
if (cfile == NULL) {
FILE* games_c_file = fopen(argv[2], "w");;
if (games_c_file == NULL) {
fprintf(stderr, "%s: can't write to file\n", argv[2]);
}
FILE* hfile = fopen(argv[3], "w");;
if (hfile == NULL) {
FILE* games_h_file = fopen(argv[3], "w");;
if (games_h_file == NULL) {
fprintf(stderr, "%s: can't write to file\n", argv[3]);
}
FILE* xfile = fopen(argv[4], "w");;
if (xfile == NULL) {
FILE* icons_c_file = fopen(argv[4], "w");;
if (icons_c_file == NULL) {
fprintf(stderr, "%s: can't write to file\n", argv[4]);
}
@ -383,56 +408,103 @@ int main (int argc, char* argv[]) {
}
}
fputs("// DO NOT EDIT THIS FILE, AUTOMATICALLY GENERATED\n", cfile);
fputs("// DO NOT EDIT THIS FILE, AUTOMATICALLY GENERATED\n", hfile);
fputs("// DO NOT EDIT THIS FILE, AUTOMATICALLY GENERATED\n", xfile);
fprintf(games_c_file, "%s\n", WARNING_HEADER);
fprintf(games_h_file, "%s\n", WARNING_HEADER);
fprintf(icons_c_file, "%s\n", WARNING_HEADER);
fputs("enum server_type {\n", hfile);
// write quake_private then unreal_private
for(i = 0; i <= 1; i++) {
for (ptr = list; ptr; ptr = ptr->next) {
buf = xmlStrdup(ptr->game->basic[TAG_type]);
for (ptr = list, type_count = 0; ptr; ptr = ptr->next, type_count++) {
for (c = buf; *c; ++c) {
if (*c == '_') {
*c = '\0';
break;
}
*c = tolower(*c);
}
ptr->game->basic[TAG_pd] = malloc(xmlStrlen(buf) + 9);
xmlStrPrintf(ptr->game->basic[TAG_pd], xmlStrlen(buf) + 9, "%s_private", buf);
free(buf);
if (ptr->game->basic[TAG_private_suffix] == NULL) {
if (i == 0)
fprintf(games_c_file, "static struct quake_private %s;\n", ptr->game->basic[TAG_pd]);
}
else {
if (i == 1)
fprintf(games_c_file, "static struct unreal_private %s = { NULL, \"%s\" };\n", ptr->game->basic[TAG_pd], ptr->game->basic[TAG_private_suffix]);
}
}
}
// write stringlist
for (ptr = list, i = 0; ptr; ptr = ptr->next) {
RawGame* rg = ptr->game;
GameTag tag;
fprintf(hfile, "\t%s%s,\n", ptr->game->basic[TAG_type], type_count == 0 ? " = 0" : "");
if (ptr->game->basic[TAG_icon] != NULL) {
fprintf(xfile, "#include \"xpm/%s\"\n", ptr->game->basic[TAG_icon]);
}
for (tag = TAG_start_multi; tag <= TAG_end_multi; ++tag) {
struct MultiTag* m = rg->multi[tag - TAG_start_multi];
if (!m && rg->base && tag_inherit(tag))
if (!m && rg->base && tag_inherit(tag)) {
m = rg->base->multi[tag - TAG_start_multi];
if (!m)
m = template->multi[tag - TAG_start_multi];
if (!m || !m->val || !xmlStrcmp(m->val, (xmlChar*) "NULL")) continue;
fprintf(cfile, "static char* stringlist%03u[] = {", i);
for (; m; m = m->next) {
fprintf(cfile, " \"%s\",", m->val);
}
fputs(" NULL };\n", cfile);
if (!m) {
m = template->multi[tag - TAG_start_multi];
}
if (!m || !m->val || !xmlStrcmp(m->val, (xmlChar*) "NULL")) {
continue;
}
fprintf(games_c_file, "static char* stringlist%03u[] = {", i);
for (; m; m = m->next) {
fprintf(games_c_file, " \"%s\",", m->val);
}
fputs(" NULL };\n", games_c_file);
++i;
}
}
fputs("};\n", hfile);
fputs("struct game games[] = {\n", games_c_file);
fputs("struct game games[] = {\n", cfile);
i = 0;
for (ptr = list; ptr; ptr = ptr->next) {
// write games list
for (ptr = list, i = 0; ptr; ptr = ptr->next) {
RawGame* rg = ptr->game;
rg->num_multitags = i;
printGame(cfile, rg, template);
printGame(games_c_file, rg, template);
i = rg->num_multitags;
free(ptr->game->basic[TAG_pd]);
}
fputs("};\n", cfile);
fputs("};\n", games_c_file);
fclose(games_c_file);
fputs("enum server_type {\n", games_h_file);
// write server_type enum
// write xpm include
for (ptr = list, i = 0; ptr; ptr = ptr->next, i++) {
fprintf(games_h_file, "\t%s%s,\n", ptr->game->basic[TAG_type], i == 0 ? " = 0" : "");
if (ptr->game->basic[TAG_icon] != NULL) {
fprintf(icons_c_file, "#include \"xpm/%s\"\n", ptr->game->basic[TAG_icon]);
}
}
fputs("};\n", games_h_file);
fclose(games_h_file);
fclose(icons_c_file);
// TODO free

View File

@ -27,7 +27,7 @@
// hack to make dlsym work
#define static
#include "icons.c"
#include ICONS_C_INCLUDE
#include "xpm/update.xpm"
#include "xpm/refresh.xpm"