diff --git a/code/game/bg_lex.h b/code/game/bg_lex.h index e3ff55d..6b606ed 100644 --- a/code/game/bg_lex.h +++ b/code/game/bg_lex.h @@ -103,6 +103,7 @@ typedef enum { LSYM_WCONF_DAMAGE, LSYM_WCONF_VARIATION, LSYM_WCONF_RADIUS, + LSYM_WCONF_SIZE, LSYM_POINT, LSYM_UNKNOWN diff --git a/code/game/bg_lex.lex b/code/game/bg_lex.lex index cd35500..008aeca 100644 --- a/code/game/bg_lex.lex +++ b/code/game/bg_lex.lex @@ -1120,6 +1120,10 @@ bgLexSymbol bgLex_textToSymbol(char* text) { return LSYM_WCONF_RADIUS; } + if(strcmp("size", text) == 0) { + return LSYM_WCONF_SIZE; + } + return LSYM_UNKNOWN; } diff --git a/code/game/bg_lex.yy.c b/code/game/bg_lex.yy.c index c7b10f3..e9aef66 100644 --- a/code/game/bg_lex.yy.c +++ b/code/game/bg_lex.yy.c @@ -3530,6 +3530,10 @@ bgLexSymbol bgLex_textToSymbol(char* text) { return LSYM_WCONF_RADIUS; } + if(strcmp("size", text) == 0) { + return LSYM_WCONF_SIZE; + } + return LSYM_UNKNOWN; } diff --git a/code/game/g_weapon.c b/code/game/g_weapon.c index ecbfcb0..071e85d 100644 --- a/code/game/g_weapon.c +++ b/code/game/g_weapon.c @@ -126,7 +126,7 @@ static qboolean G_Weapon_ParseWeaponConfig(bgLex* lexer) { return qfalse; } break; - default: + default: G_Logger(LL_ERROR, "Unexpected token at weapons.cfg.%d:%d!\n", lexer->morphem.line, lexer->morphem.column); G_LogFuncEnd(); return qfalse; @@ -199,7 +199,107 @@ static qboolean G_Weapon_ParseWeaponConfig(bgLex* lexer) { } break; case LSYM_WCONF_CRIFLE: - + while (bgLex_lex(lexer) != 0) { + 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; + } else { + 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_DAMAGE: + bgLex_lex(lexer); + if (lexer->morphem.type == LMT_INT) { + weaponConfig.crifle.primary.damage = lexer->morphem.data.numInteger; + } 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; + case LSYM_WCONF_RANGE: + bgLex_lex(lexer); + if (lexer->morphem.type == LMT_DOUBLE) { + weaponConfig.crifle.primary.range = lexer->morphem.data.numDouble; + } else { + G_Logger(LL_ERROR, "Expected double 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_DAMAGE: + bgLex_lex(lexer); + if (lexer->morphem.type == LMT_INT) { + weaponConfig.crifle.secondary.damage = lexer->morphem.data.numInteger; + } 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; + case LSYM_WCONF_RANGE: + bgLex_lex(lexer); + if (lexer->morphem.type == LMT_DOUBLE) { + weaponConfig.crifle.secondary.range = lexer->morphem.data.numDouble; + } else { + G_Logger(LL_ERROR, "Expected double value at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column); + G_LogFuncEnd(); + return qfalse; + } + break; + case LSYM_WCONF_SIZE: + bgLex_lex(lexer); + if (lexer->morphem.type == LMT_INT) { + weaponConfig.crifle.secondary.size = lexer->morphem.data.numInteger; + } 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, "Expected 'primary' or 'secondary' at weapons.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column); + G_LogFuncEnd(); + return qfalse; + } + } + } break; case LSYM_WCONF_DISRUPTOR: