I'm trying to fix a bug in Quake 2, with the Quake 2 Engine.
if is really in C and not C++, please move this topic to the right place. thanks!
well, I know the cause of this bug and the solution, and I could fix with 2 easy ways, but I can't do it in this MOD because I don't have the MOD source where the exact line can't be changed, so override my fix in the original code (which I have the source) when loaded.
So I need to change in the harder way, changing the positions of the spawnpoints to a little higher when load the maps, and in this funcion below is where the entity list of the map is loaded:
Code:
/*
=================
CM_LoadEntityString
=================
*/
static void CM_LoadEntityString (const byte *data, const lump_t *l){
cm_numEntityChars = l->fileLen;
if (cm_numEntityChars < 1)
return;
if (cm_numEntityChars > MAX_MAP_ENTSTRING)
Com_Error(ERR_DROP, "CM_LoadMap: map '%s' has too large entity lump", cm_map);
cm_entityString = Hunk_Alloc(cm_numEntityChars + 1);
memcpy(cm_entityString, data + l->fileOfs, cm_numEntityChars);
}
than I need this:
Code:
/*
=================
CM_LoadEntityString
=================
*/
static void CM_LoadEntityString (const byte *data, const lump_t *l){
char *game = Cvar_VariableString("fs_game");
cm_numEntityChars = l->fileLen;
if (cm_numEntityChars < 1)
return;
if (cm_numEntityChars > MAX_MAP_ENTSTRING)
Com_Error(ERR_DROP, "CM_LoadMap: map '%s' has too large entity lump", cm_map);
cm_entityString = Hunk_Alloc(cm_numEntityChars + 1);
memcpy(cm_entityString, data + l->fileOfs, cm_numEntityChars);
if (!Q_stricmp(game, "arena")){
// do string manipulation over cm_entityString
}
}
so will only do the change when the game is "arena" (which means the MOD arena), which is compiling and working...
now I need to make that pseudo-code that I created to make this work.
Code:
set working = 1;
while working == 1 {
if "{" not found{
set working = 0;
else{
subs = GetSubstring(String, first {, first });
Str1 = GetSubstring (String[0], subs[0]);
Str2 = GetSubstring (subs[size],String[size]);
if found (info_player_deathmatch || info_player_start) in subs {
find "origin" location;
posA = find 3rd space after origin location;
posB = find next " after posA;
Subs1 = GetSubstring (subs[0],posA);
Subs2 = GetSubstring (posB,subs[size]);
num = GetSubstring (posA, posB);
ToNumber(num) += 15;
subs = Subs1 + num + Subs2;
ReplaceAll (subs, {, [);
ReplaceAll (subs, }, ]);
}
}
}
ReplaceAll (String, [, {);
ReplaceAll (String, ], });
than I started:
Code:
/*
=================
CM_LoadEntityString
=================
*/
static void CM_LoadEntityString (const byte *data, const lump_t *l){
char *game = Cvar_VariableString("fs_game");
int working = 1;
cm_numEntityChars = l->fileLen;
if (cm_numEntityChars < 1)
return;
if (cm_numEntityChars > MAX_MAP_ENTSTRING)
Com_Error(ERR_DROP, "CM_LoadMap: map '%s' has too large entity lump", cm_map);
cm_entityString = Hunk_Alloc(cm_numEntityChars + 1);
memcpy(cm_entityString, data + l->fileOfs, cm_numEntityChars);
if (!Q_stricmp(game, "arena")){
// do string manipulation over cm_entityString
while (working == 1){
if (cm_entityString.find_first_of("{"){
working = 0;
}else{
// other stuff
}
}
}
}
than I'm receiving this error:
Code:
qcommon\cmodel.c(508) : error C2224: left of '.find_first_of' must have struct/union type
qcommon\cmodel.c(508) : error C2143: syntax error : missing ')' before '{'
more info about this problem at this link
that's all! anyone could help with that?