From: Holger Schemel Date: Fri, 7 Oct 2016 06:46:31 +0000 (+0200) Subject: fixed bug with special flag 'load_xsb_to_ces' (use level template size instead of... X-Git-Tag: 4.0.0.0~40 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f7cfbcfe490a20f60a778ff9b05f174fab1ec2da;p=rocksndiamonds.git fixed bug with special flag 'load_xsb_to_ces' (use level template size instead of playfield size) --- diff --git a/src/files.c b/src/files.c index f2ff5d21..df569c52 100644 --- a/src/files.c +++ b/src/files.c @@ -1786,10 +1786,41 @@ static void setFileInfoToDefaults(struct LevelFileInfo *level_file_info) level_file_info->filename = NULL; } +int getMappedElement_SB(int, boolean); + static void ActivateLevelTemplate() { int x, y; + if (check_special_flags("load_xsb_to_ces")) + { + /* fill smaller playfields with padding "beyond border wall" elements */ + if (level.fieldx < level_template.fieldx || + level.fieldy < level_template.fieldy) + { + short field[level.fieldx][level.fieldy]; + int new_fieldx = MAX(level.fieldx, level_template.fieldx); + int new_fieldy = MAX(level.fieldy, level_template.fieldy); + int pos_fieldx = (new_fieldx - level.fieldx) / 2; + int pos_fieldy = (new_fieldy - level.fieldy) / 2; + + /* copy old playfield (which is smaller than the visible area) */ + for (y = 0; y < level.fieldy; y++) for (x = 0; x < level.fieldx; x++) + field[x][y] = level.field[x][y]; + + /* fill new, larger playfield with "beyond border wall" elements */ + for (y = 0; y < new_fieldy; y++) for (x = 0; x < new_fieldx; x++) + level.field[x][y] = getMappedElement_SB('_', TRUE); + + /* copy the old playfield to the middle of the new playfield */ + for (y = 0; y < level.fieldy; y++) for (x = 0; x < level.fieldx; x++) + level.field[pos_fieldx + x][pos_fieldy + y] = field[x][y]; + + level.fieldx = new_fieldx; + level.fieldy = new_fieldy; + } + } + /* Currently there is no special action needed to activate the template data, because 'element_info' property settings overwrite the original level data, while all other variables do not change. */ @@ -5756,32 +5787,6 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, { /* special global settings can now be set in level template */ - /* fill smaller playfields with padding "beyond border wall" elements */ - if (level->fieldx < SCR_FIELDX || - level->fieldy < SCR_FIELDY) - { - short field[level->fieldx][level->fieldy]; - int new_fieldx = MAX(level->fieldx, SCR_FIELDX); - int new_fieldy = MAX(level->fieldy, SCR_FIELDY); - int pos_fieldx = (new_fieldx - level->fieldx) / 2; - int pos_fieldy = (new_fieldy - level->fieldy) / 2; - - /* copy old playfield (which is smaller than the visible area) */ - for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) - field[x][y] = level->field[x][y]; - - /* fill new, larger playfield with "beyond border wall" elements */ - for (y = 0; y < new_fieldy; y++) for (x = 0; x < new_fieldx; x++) - level->field[x][y] = getMappedElement_SB('_', load_xsb_to_ces); - - /* copy the old playfield to the middle of the new playfield */ - for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) - level->field[pos_fieldx + x][pos_fieldy + y] = field[x][y]; - - level->fieldx = new_fieldx; - level->fieldy = new_fieldy; - } - level->use_custom_template = TRUE; } }