C++ conversion: fixed compilation errors for botlib project.

This commit is contained in:
Artem Kharytoniuk 2014-05-11 00:36:35 +03:00
parent ff834b8b59
commit 0153ac316f
13 changed files with 58 additions and 103 deletions

View File

@ -190,7 +190,7 @@ qboolean AAS_EntityCollision(int entnum,
//===========================================================================
qboolean AAS_inPVS(vec3_t p1, vec3_t p2)
{
return botimport.inPVS(p1, p2);
return (qboolean) botimport.inPVS(p1, p2);
} //end of the function AAS_InPVS
//===========================================================================
// returns true if in Potentially Visible Set

View File

@ -390,9 +390,9 @@ int AAS_NearestEntity(vec3_t origin, int modelindex)
ent = &aasworld.entities[i];
if (ent->i.modelindex != modelindex) continue;
VectorSubtract(ent->i.origin, origin, dir);
if (abs(dir[0]) < 40)
if (fabs(dir[0]) < 40)
{
if (abs(dir[1]) < 40)
if (fabs(dir[1]) < 40)
{
dist = VectorLength(dir);
if (dist < bestdist)

View File

@ -168,7 +168,7 @@ int AAS_AgainstLadder(vec3_t origin)
//get the plane the face is in
plane = &aasworld.planes[face->planenum ^ side];
//if the origin is pretty close to the plane
if (abs(DotProduct(plane->normal, origin) - plane->dist) < 3)
if (fabs(DotProduct(plane->normal, origin) - plane->dist) < 3)
{
if (AAS_PointInsideFace(abs(facenum), origin, 0.1f)) return qtrue;
} //end if

View File

@ -592,7 +592,7 @@ int AAS_FallDamageDistance(void)
{
float maxzvelocity, gravity, t;
maxzvelocity = sqrt(30 * 10000);
maxzvelocity = sqrt(30.f * 10000.f);
gravity = aassettings.phys_gravity;
t = maxzvelocity / gravity;
return 0.5 * gravity * t * t;
@ -2478,8 +2478,8 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
VectorMA(area1point, -32, dir, area1point);
VectorMA(area2point, 32, dir, area2point);
//
ladderface1vertical = abs(DotProduct(plane1->normal, up)) < 0.1;
ladderface2vertical = abs(DotProduct(plane2->normal, up)) < 0.1;
ladderface1vertical = fabs(DotProduct(plane1->normal, up)) < 0.1;
ladderface2vertical = fabs(DotProduct(plane2->normal, up)) < 0.1;
//there's only reachability between vertical ladder faces
if (!ladderface1vertical && !ladderface2vertical) return qfalse;
//if both vertical ladder faces
@ -2487,7 +2487,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
//and the ladder faces do not make a sharp corner
&& DotProduct(plane1->normal, plane2->normal) > 0.7
//and the shared edge is not too vertical
&& abs(DotProduct(sharededgevec, up)) < 0.7)
&& fabs(DotProduct(sharededgevec, up)) < 0.7)
{
//create a new reachability link
lreach = AAS_AllocReachability();
@ -2612,7 +2612,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
if (face2->faceflags & FACE_LADDER)
{
plane2 = &aasworld.planes[face2->planenum];
if (abs(DotProduct(plane2->normal, up)) < 0.1) break;
if (fabs(DotProduct(plane2->normal, up)) < 0.1) break;
} //end if
} //end for
//if from another area without vertical ladder faces

View File

@ -606,34 +606,8 @@ aas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype,
//the current node plane
plane = &aasworld.planes[aasnode->planenum];
switch(plane->type)
{/*FIXME: wtf doesn't this work? obviously the axial node planes aren't always facing positive!!!
//check for axial planes
case PLANE_X:
{
front = cur_start[0] - plane->dist;
back = cur_end[0] - plane->dist;
break;
} //end case
case PLANE_Y:
{
front = cur_start[1] - plane->dist;
back = cur_end[1] - plane->dist;
break;
} //end case
case PLANE_Z:
{
front = cur_start[2] - plane->dist;
back = cur_end[2] - plane->dist;
break;
} //end case*/
default: //gee it's not an axial plane
{
front = DotProduct(cur_start, plane->normal) - plane->dist;
back = DotProduct(cur_end, plane->normal) - plane->dist;
break;
} //end default
} //end switch
// bk010221 - old location of FPE hack and divide by zero expression
//if the whole to be traced line is totally at the front of this node
//only go down the tree with the front child
@ -797,34 +771,8 @@ int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int max
//the current node plane
plane = &aasworld.planes[aasnode->planenum];
switch(plane->type)
{/*FIXME: wtf doesn't this work? obviously the node planes aren't always facing positive!!!
//check for axial planes
case PLANE_X:
{
front = cur_start[0] - plane->dist;
back = cur_end[0] - plane->dist;
break;
} //end case
case PLANE_Y:
{
front = cur_start[1] - plane->dist;
back = cur_end[1] - plane->dist;
break;
} //end case
case PLANE_Z:
{
front = cur_start[2] - plane->dist;
back = cur_end[2] - plane->dist;
break;
} //end case*/
default: //gee it's not an axial plane
{
front = DotProduct(cur_start, plane->normal) - plane->dist;
back = DotProduct(cur_end, plane->normal) - plane->dist;
break;
} //end default
} //end switch
//if the whole to be traced line is totally at the front of this node
//only go down the tree with the front child

View File

@ -302,7 +302,7 @@ bot_character_t *BotLoadCharacterFromFile(char *charfile, int skill)
else if (token.type == TT_STRING)
{
StripDoubleQuotes(token.string);
ch->c[index].value.string = GetMemory((int)strlen(token.string)+1);
ch->c[index].value.string = (char*)GetMemory((int)strlen(token.string)+1);
strcpy(ch->c[index].value.string, token.string);
ch->c[index].type = CT_STRING;
} //end else if

View File

@ -1552,7 +1552,7 @@ bot_stringlist_t *BotCheckChatMessageIntegrety(char *message, bot_stringlist_t *
if (!BotFindStringInList(stringlist, temp))
{
Log_Write("%s = {\"%s\"} //MISSING RANDOM\r\n", temp, temp);
s = GetClearedMemory(sizeof(bot_stringlist_t) + (int)strlen(temp) + 1);
s = (bot_stringlist_t*) GetClearedMemory(sizeof(bot_stringlist_t) + (int)strlen(temp) + 1);
s->string = (char *) s + sizeof(bot_stringlist_t);
strcpy(s->string, temp);
s->next = stringlist;
@ -1855,7 +1855,7 @@ bot_replychat_t *BotLoadReplyChat(char *filename)
return NULL;
} //end if
//
replychat = GetClearedHunkMemory(sizeof(bot_replychat_t));
replychat = (bot_replychat_t*) GetClearedHunkMemory(sizeof(bot_replychat_t));
replychat->keys = NULL;
replychat->next = replychatlist;
replychatlist = replychat;
@ -2241,7 +2241,7 @@ int BotLoadChatFile(int chatstate, char *chatfile, char *chatname)
} //end if
if (!LibVarGetValue("bot_reloadcharacters"))
{
ichatdata[avail] = GetClearedMemory( sizeof(bot_ichatdata_t) );
ichatdata[avail] = (bot_ichatdata_t*) GetClearedMemory( sizeof(bot_ichatdata_t) );
ichatdata[avail]->chat = cs->chat;
Q_strncpyz( ichatdata[avail]->chatname, chatname, sizeof(ichatdata[avail]->chatname) );
Q_strncpyz( ichatdata[avail]->filename, chatfile, sizeof(ichatdata[avail]->filename) );
@ -2900,7 +2900,7 @@ int BotAllocChatState(void)
{
if (!botchatstates[i])
{
botchatstates[i] = GetClearedMemory(sizeof(bot_chatstate_t));
botchatstates[i] = (bot_chatstate_t*) GetClearedMemory(sizeof(bot_chatstate_t));
return i;
} //end if
} //end for

View File

@ -1736,7 +1736,7 @@ int BotAllocGoalState(int client)
{
if (!botgoalstates[i])
{
botgoalstates[i] = GetClearedMemory(sizeof(bot_goalstate_t));
botgoalstates[i] = (bot_goalstate_t*) GetClearedMemory(sizeof(bot_goalstate_t));
botgoalstates[i]->client = client;
return i;
} //end if

View File

@ -132,7 +132,7 @@ int BotAllocMoveState(void)
{
if (!botmovestates[i])
{
botmovestates[i] = GetClearedMemory(sizeof(bot_movestate_t));
botmovestates[i] = (bot_movestate_t*) GetClearedMemory(sizeof(bot_movestate_t));
return i;
} //end if
} //end for
@ -2093,7 +2093,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
botimport.Print(PRT_MESSAGE, "bot on elevator\n");
#endif //DEBUG_ELEVATOR
//if vertically not too far from the end point
if (abs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
if (fabs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
{
#ifdef DEBUG_ELEVATOR
botimport.Print(PRT_MESSAGE, "bot moving to end\n");

View File

@ -467,7 +467,7 @@ int BotAllocWeaponState(void)
{
if (!botweaponstates[i])
{
botweaponstates[i] = GetClearedMemory(sizeof(bot_weaponstate_t));
botweaponstates[i] = (bot_weaponstate_t*) GetClearedMemory(sizeof(bot_weaponstate_t));
return i;
} //end if
} //end for

View File

@ -665,10 +665,13 @@ void PC_AddBuiltinDefines(source_t *source)
{
int i;
define_t *define;
struct builtin
struct builtinStruct
{
char *string;
int builtin;
builtinStruct(char* istring, int ibuiltin)
: string(istring), builtin(ibuiltin) {}
} builtin[] = { // bk001204 - brackets
{ "__LINE__", BUILTIN_LINE },
{ "__FILE__", BUILTIN_FILE },
@ -736,7 +739,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define
case BUILTIN_DATE:
{
t = time(NULL);
curtime = ctime(&t);
curtime = ctime((const time_t*)&t);
strcpy(token->string, "\"");
strncat(token->string, curtime+4, 7);
strncat(token->string+7, curtime+20, 4);
@ -751,7 +754,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define
case BUILTIN_TIME:
{
t = time(NULL);
curtime = ctime(&t);
curtime = ctime((const time_t*)&t);
strcpy(token->string, "\"");
strncat(token->string, curtime+11, 8);
strcat(token->string, "\"");
@ -1331,7 +1334,7 @@ define_t *PC_DefineFromString(char *string)
strncpy(src.filename, "*extern", MAX_PATH);
src.scriptstack = script;
#if DEFINEHASHING
src.definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));
src.definehash = (define_t**) GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));
#endif //DEFINEHASHING
//create a define from the source
res = PC_Directive_define(&src);
@ -1606,7 +1609,7 @@ int PC_Directive_endif(source_t *source)
//============================================================================
typedef struct operator_s
{
int operator;
int operatorCode;
int priority;
int parentheses;
struct operator_s *prev, *next;
@ -1914,7 +1917,7 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval
{
//o = (operator_t *) GetClearedMemory(sizeof(operator_t));
AllocOperator(o);
o->operator = t->subtype;
o->operatorCode = t->subtype;
o->priority = PC_OperatorPriority(t->subtype);
o->parentheses = parentheses;
o->next = NULL;
@ -1969,8 +1972,8 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval
if (o->priority >= o->next->priority) break;
} //end if
//if the arity of the operator isn't equal to 1
if (o->operator != P_LOGIC_NOT
&& o->operator != P_BIN_NOT) v = v->next;
if (o->operatorCode != P_LOGIC_NOT
&& o->operatorCode != P_BIN_NOT) v = v->next;
//if there's no value or no next value
if (!v)
{
@ -1994,7 +1997,7 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval
if (v2) Log_Write("value2 = %f", v2->floatvalue);
} //end else
#endif //DEBUG_EVAL
switch(o->operator)
switch(o->operatorCode)
{
case P_LOGIC_NOT: v1->intvalue = !v1->intvalue;
v1->floatvalue = !v1->floatvalue; break;
@ -2085,13 +2088,13 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval
else Log_Write("result value = %f", v1->floatvalue);
#endif //DEBUG_EVAL
if (error) break;
lastoperatortype = o->operator;
lastoperatortype = o->operatorCode;
//if not an operator with arity 1
if (o->operator != P_LOGIC_NOT
&& o->operator != P_BIN_NOT)
if (o->operatorCode != P_LOGIC_NOT
&& o->operatorCode != P_BIN_NOT)
{
//remove the second value if not question mark operator
if (o->operator != P_QUESTIONMARK) v = v->next;
if (o->operatorCode != P_QUESTIONMARK) v = v->next;
//
if (v->prev) v->prev->next = v->next;
else firstvalue = v->next;
@ -3002,7 +3005,7 @@ source_t *LoadSourceFile(const char *filename)
source->skip = 0;
#if DEFINEHASHING
source->definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));
source->definehash = (define_t**) GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));
#endif //DEFINEHASHING
PC_AddGlobalDefinesToSource(source);
return source;
@ -3035,7 +3038,7 @@ source_t *LoadSourceMemory(char *ptr, int length, char *name)
source->skip = 0;
#if DEFINEHASHING
source->definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));
source->definehash = (define_t**) GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));
#endif //DEFINEHASHING
PC_AddGlobalDefinesToSource(source);
return source;

View File

@ -80,7 +80,7 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
long int intval, intmin = 0, intmax = 0;
double floatval;
if (!PC_ExpectAnyToken(source, &token)) return 0;
if (!PC_ExpectAnyToken(source, &token)) return (qboolean) 0;
//check for minus sign
if (token.type == TT_PUNCTUATION)
@ -88,23 +88,23 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
if (fd->type & FT_UNSIGNED)
{
SourceError(source, "expected unsigned value, found %s", token.string);
return 0;
return (qboolean) 0;
} //end if
//if not a minus sign
if (strcmp(token.string, "-"))
{
SourceError(source, "unexpected punctuation %s", token.string);
return 0;
return (qboolean) 0;
} //end if
negative = qtrue;
//read the number
if (!PC_ExpectAnyToken(source, &token)) return 0;
if (!PC_ExpectAnyToken(source, &token)) return (qboolean) 0;
} //end if
//check if it is a number
if (token.type != TT_NUMBER)
{
SourceError(source, "expected number, found %s", token.string);
return 0;
return (qboolean) 0;
} //end if
//check for a float value
if (token.subtype & TT_FLOAT)
@ -112,7 +112,7 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
if ((fd->type & FT_TYPE) != FT_FLOAT)
{
SourceError(source, "unexpected float");
return 0;
return (qboolean) 0;
} //end if
floatval = token.floatvalue;
if (negative) floatval = -floatval;
@ -121,11 +121,11 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
if (floatval < fd->floatmin || floatval > fd->floatmax)
{
SourceError(source, "float out of range [%f, %f]", fd->floatmin, fd->floatmax);
return 0;
return (qboolean) 0;
} //end if
} //end if
*(float *) p = (float) floatval;
return 1;
return (qboolean) 1;
} //end if
//
intval = token.intvalue;
@ -151,7 +151,7 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
if (intval < intmin || intval > intmax)
{
SourceError(source, "value %d out of range [%d, %d]", intval, intmin, intmax);
return 0;
return (qboolean) 0;
} //end if
} //end if
else if ((fd->type & FT_TYPE) == FT_FLOAT)
@ -161,7 +161,7 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
if (intval < fd->floatmin || intval > fd->floatmax)
{
SourceError(source, "value %d out of range [%f, %f]", intval, fd->floatmin, fd->floatmax);
return 0;
return (qboolean) 0;
} //end if
} //end if
} //end else if
@ -180,7 +180,7 @@ qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)
{
*(float *) p = (float) intval;
} //end else
return 1;
return (qboolean) 1;
} //end of the function ReadNumber
//===========================================================================
//
@ -192,7 +192,7 @@ qboolean ReadChar(source_t *source, fielddef_t *fd, void *p)
{
token_t token;
if (!PC_ExpectAnyToken(source, &token)) return 0;
if (!PC_ExpectAnyToken(source, &token)) return (qboolean) 0;
//take literals into account
if (token.type == TT_LITERAL)
@ -203,9 +203,9 @@ qboolean ReadChar(source_t *source, fielddef_t *fd, void *p)
else
{
PC_UnreadLastToken(source);
if (!ReadNumber(source, fd, p)) return 0;
if (!ReadNumber(source, fd, p)) return (qboolean) 0;
} //end if
return 1;
return (qboolean) 1;
} //end of the function ReadChar
//===========================================================================
//

View File

@ -106,6 +106,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -131,6 +132,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -155,6 +157,7 @@
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -179,6 +182,7 @@
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>