Added weapon config parser function for hyperspanner.

This commit is contained in:
Walter Julius Hennecke 2014-10-07 21:27:31 +02:00
parent 28013fc6ca
commit 8a2870cac2
4 changed files with 94 additions and 1 deletions

View file

@ -107,6 +107,7 @@ typedef enum {
LSYM_WCONF_TIME, LSYM_WCONF_TIME,
LSYM_WCONF_VELOCITY, LSYM_WCONF_VELOCITY,
LSYM_WCONF_SPLASH, LSYM_WCONF_SPLASH,
LSYM_WCONF_RATE,
LSYM_POINT, LSYM_POINT,
LSYM_UNKNOWN LSYM_UNKNOWN

View file

@ -1136,6 +1136,10 @@ bgLexSymbol bgLex_textToSymbol(char* text) {
return LSYM_WCONF_SPLASH; return LSYM_WCONF_SPLASH;
} }
if(strcmp("rate", text) == 0) {
return LSYM_WCONF_RATE;
}
return LSYM_UNKNOWN; return LSYM_UNKNOWN;
} }

View file

@ -3546,6 +3546,10 @@ bgLexSymbol bgLex_textToSymbol(char* text) {
return LSYM_WCONF_SPLASH; return LSYM_WCONF_SPLASH;
} }
if(strcmp("rate", text) == 0) {
return LSYM_WCONF_RATE;
}
return LSYM_UNKNOWN; return LSYM_UNKNOWN;
} }

View file

@ -663,7 +663,91 @@ static qboolean G_Weapon_ParseConfigDisruptor(bgLex* lexer) {
} }
static qboolean G_Weapon_ParseConfigHyperspanner(bgLex* lexer) { static qboolean G_Weapon_ParseConfigHyperspanner(bgLex* lexer) {
return qfalse; G_LogFuncBegin();
G_Assert(lexer, qfalse);
bgLex_lex(lexer);
if (lexer->morphem.type == LMT_SYMBOL && lexer->morphem.data.symbol == LSYM_POINT) {
bgLex_lex(lexer);
if (lexer->morphem.type == LMT_SYMBOL) {
if (lexer->morphem.data.symbol == LSYM_WCONF_PRIMARY) {
bgLex_lex(lexer);
if (lexer->morphem.type != LMT_SYMBOL || lexer->morphem.data.symbol != LSYM_POINT) {
G_Logger(LL_ERROR, "Expected '.' at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
bgLex_lex(lexer);
if (lexer->morphem.type != LMT_SYMBOL) {
G_Logger(LL_ERROR, "Unexpected token at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
switch (lexer->morphem.data.symbol) {
case LSYM_WCONF_RATE:
bgLex_lex(lexer);
if (lexer->morphem.type == LMT_INT) {
weaponConfig.hyperspanner.primary.rate = lexer->morphem.data.numInteger;
G_LogFuncEnd();
return qtrue;
} else {
G_Logger(LL_ERROR, "Expected integer value at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
break;
default:
G_Logger(LL_ERROR, "Unexpected token at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
} else if (lexer->morphem.data.symbol == LSYM_WCONF_SECONDARY) {
bgLex_lex(lexer);
if (lexer->morphem.type != LMT_SYMBOL || lexer->morphem.data.symbol != LSYM_POINT) {
G_Logger(LL_ERROR, "Expected '.' at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
bgLex_lex(lexer);
if (lexer->morphem.type != LMT_SYMBOL) {
G_Logger(LL_ERROR, "Unexpected token at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
switch (lexer->morphem.data.symbol) {
case LSYM_WCONF_RATE:
bgLex_lex(lexer);
if (lexer->morphem.type == LMT_INT) {
weaponConfig.hyperspanner.secondary.rate = lexer->morphem.data.numInteger;
G_LogFuncEnd();
return qtrue;
} else {
G_Logger(LL_ERROR, "Expected integer value at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
break;
default:
G_Logger(LL_ERROR, "Unexpected token at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
} else {
G_Logger(LL_ERROR, "Unexpected token at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
} else {
G_Logger(LL_ERROR, "Unexpected token at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
} else {
G_Logger(LL_ERROR, "Expected '.' at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column);
G_LogFuncEnd();
return qfalse;
}
} }
static qboolean G_Weapon_ParseConfigTR116(bgLex* lexer) { static qboolean G_Weapon_ParseConfigTR116(bgLex* lexer) {