Skip to content

Commit

Permalink
Fixed map specific shot/spell/power names (#3687)
Browse files Browse the repository at this point in the history
- Also fixed recent unneeded log errors
- Fixes #3388
  • Loading branch information
Loobinex authored Nov 17, 2024
1 parent 68fad32 commit a2974c2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/bflib_dernc.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ long LbFileLengthRnc(const char *fname)
long flength;
TbFileHandle handle = LbFileOpen(fname, Lb_FILE_MODE_READ_ONLY);
if (!handle) {
LbSyncLog("%s: failed to open\n", fname);
return -1;
}
#if (BFDEBUG_LEVEL > 19)
Expand Down
82 changes: 53 additions & 29 deletions src/config_magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,14 @@ TbBool parse_magic_spell_blocks(char *buf, long len, const char *config_textname
// Initialize the array
for (int i = 0; i < MAGIC_ITEMS_MAX; i++) {
spellst = &game.conf.magic_conf.spell_cfgstats[i];
if (((flags & CnfLd_AcceptPartial) == 0) || (strlen(spellst->code_name) <= 0)) {
LbMemorySet(&spellst->code_name, 0, COMMAND_WORD_LEN);
spell_desc[i].name = spellst->code_name;
spell_desc[i].num = i;
if ((!flag_is_set(flags,CnfLd_AcceptPartial)) || (strlen(spellst->code_name) <= 0))
{
if (flag_is_set(flags, CnfLd_ListOnly))
{
LbMemorySet(&spellst->code_name, 0, COMMAND_WORD_LEN);
spell_desc[i].name = spellst->code_name;
spell_desc[i].num = i;
}
spconf = &game.conf.magic_conf.spell_config[i];
spconf->linked_power = 0;
spconf->duration = 0;
Expand Down Expand Up @@ -474,11 +478,10 @@ TbBool parse_magic_spell_blocks(char *buf, long len, const char *config_textname
int cmd_num = recognize_conf_command(buf, &pos, len, magic_spell_commands);
// Now store the config item in correct place
if (cmd_num == ccr_endOfBlock) break; // if next block starts
if ((flags & CnfLd_ListOnly) != 0) {
// In "List only" mode, accept only name command
if (cmd_num > 1) {
cmd_num = 0;
}
//Do the name when listing, the rest when not listing.
if ((flag_is_set(flags, CnfLd_ListOnly) && cmd_num > 1) || (!flag_is_set(flags, CnfLd_ListOnly) && cmd_num <= 1))
{
cmd_num = ccr_comment;
}
int n = 0, k = 0;
char word_buf[COMMAND_WORD_LEN];
Expand All @@ -491,6 +494,11 @@ TbBool parse_magic_spell_blocks(char *buf, long len, const char *config_textname
COMMAND_TEXT(cmd_num), blocknamelen, blockname, config_textname);
break;
}
else
{
spell_desc[i].name = spellst->code_name;
spell_desc[i].num = i;
}
n++;
break;
case 2: // DURATION
Expand Down Expand Up @@ -729,11 +737,15 @@ TbBool parse_magic_shot_blocks(char *buf, long len, const char *config_textname,
// Initialize the array
for (int i = 0; i < MAGIC_ITEMS_MAX; i++) {
shotst = &game.conf.magic_conf.shot_cfgstats[i];
if (((flags & CnfLd_AcceptPartial) == 0) || (strlen(shotst->code_name) <= 0)) {
LbMemorySet(shotst->code_name, 0, COMMAND_WORD_LEN);
if ((!flag_is_set(flags,CnfLd_AcceptPartial)) || (strlen(shotst->code_name) <= 0))
{
if (flag_is_set(flags, CnfLd_ListOnly))
{
LbMemorySet(shotst->code_name, 0, COMMAND_WORD_LEN);
shot_desc[i].name = shotst->code_name;
shot_desc[i].num = i;
}
shotst->model_flags = 0;
shot_desc[i].name = shotst->code_name;
shot_desc[i].num = i;
shotst->area_hit_type = THit_CrtrsOnly;
shotst->area_range = 0;
shotst->area_damage = 0;
Expand Down Expand Up @@ -795,23 +807,27 @@ TbBool parse_magic_shot_blocks(char *buf, long len, const char *config_textname,
int cmd_num = recognize_conf_command(buf, &pos, len, magic_shot_commands);
// Now store the config item in correct place
if (cmd_num == ccr_endOfBlock) break; // if next block starts
if ((flags & CnfLd_ListOnly) != 0) {
// In "List only" mode, accept only name command
if (cmd_num > 1) {
cmd_num = 0;
}
//Do the name when listing, the rest when not listing.
if ((flag_is_set(flags, CnfLd_ListOnly) && cmd_num > 1) || (!flag_is_set(flags, CnfLd_ListOnly) && cmd_num <= 1))
{
cmd_num = ccr_comment;
}
int n = 0, k = 0;
char word_buf[COMMAND_WORD_LEN];
switch (cmd_num)
{
case 1: // NAME
if (get_conf_parameter_single(buf,&pos,len,shotst->code_name,COMMAND_WORD_LEN) <= 0)
if (get_conf_parameter_single(buf, &pos, len, shotst->code_name, COMMAND_WORD_LEN) <= 0)
{
CONFWRNLOG("Couldn't read \"%s\" parameter in [%.*s] block of %s file.",
COMMAND_TEXT(cmd_num), blocknamelen, blockname, config_textname);
break;
}
else
{
shot_desc[i].name = shotst->code_name;
shot_desc[i].num = i;
}
n++;
break;
case 2: // HEALTH
Expand Down Expand Up @@ -1809,8 +1825,14 @@ TbBool parse_magic_power_blocks(char *buf, long len, const char *config_textname
// Initialize the array
for (int i = 0; i < MAGIC_ITEMS_MAX; i++) {
powerst = &game.conf.magic_conf.power_cfgstats[i];
if (((flags & CnfLd_AcceptPartial) == 0) || (strlen(powerst->code_name) <= 0)) {
LbMemorySet(powerst->code_name, 0, COMMAND_WORD_LEN);
if ((!flag_is_set(flags,CnfLd_AcceptPartial)) || (strlen(powerst->code_name) <= 0))
{
if (flag_is_set(flags, CnfLd_ListOnly))
{
LbMemorySet(powerst->code_name, 0, COMMAND_WORD_LEN);
power_desc[i].name = powerst->code_name;
power_desc[i].num = i;
}
powerst->artifact_model = 0;
powerst->can_cast_flags = 0;
powerst->config_flags = 0;
Expand All @@ -1825,11 +1847,9 @@ TbBool parse_magic_power_blocks(char *buf, long len, const char *config_textname
powerst->panel_tab_idx = 0;
powerst->select_sound_idx = 0;
powerst->cast_cooldown = 0;
power_desc[i].name = powerst->code_name;
power_desc[i].num = i;
}
}
if ((flags & CnfLd_AcceptPartial) == 0) {
if (!flag_is_set(flags, CnfLd_AcceptPartial)) {
for (int i = 0; i < MAGIC_ITEMS_MAX; i++) {
game.conf.object_conf.object_to_power_artifact[i] = 0;
}
Expand Down Expand Up @@ -1862,11 +1882,10 @@ TbBool parse_magic_power_blocks(char *buf, long len, const char *config_textname
int cmd_num = recognize_conf_command(buf, &pos, len, magic_power_commands);
// Now store the config item in correct place
if (cmd_num == ccr_endOfBlock) break; // if next block starts
if ((flags & CnfLd_ListOnly) != 0) {
// In "List only" mode, accept only name command
if (cmd_num > 1) {
cmd_num = 0;
}
//Do the name when listing, the rest when not listing.
if ((flag_is_set(flags, CnfLd_ListOnly) && cmd_num > 1) || (!flag_is_set(flags, CnfLd_ListOnly) && cmd_num <= 1))
{
cmd_num = ccr_comment;
}
int n = 0;
char word_buf[COMMAND_WORD_LEN];
Expand All @@ -1879,6 +1898,11 @@ TbBool parse_magic_power_blocks(char *buf, long len, const char *config_textname
COMMAND_TEXT(cmd_num), blocknamelen, blockname, config_textname);
break;
}
else
{
power_desc[i].name = powerst->code_name;
power_desc[i].num = i;
}
break;
case 2: // POWER
while (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
Expand Down

0 comments on commit a2974c2

Please sign in to comment.