From: Holger Schemel Date: Thu, 7 Jan 2010 16:09:59 +0000 (+0100) Subject: rnd-20100107-2-src X-Git-Tag: 3.3.0.0^2~49 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2919379746c92fd488b83c61b328ef17fe500985;p=rocksndiamonds.git rnd-20100107-2-src * added handling of gravity ports when converting Supaplex style R'n'D levels to native Supaplex levels for playing with Supaplex engine --- diff --git a/ChangeLog b/ChangeLog index fc0dd1c7..17c8df15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-07 + * added handling of gravity ports when converting Supaplex style R'n'D + levels to native Supaplex levels for playing with Supaplex engine + 2010-01-06 * fixed bug in Supaplex engine regarding initial screen scroll position diff --git a/src/conftime.h b/src/conftime.h index 86fdfa27..587a3c61 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-01-07 00:44" +#define COMPILE_DATE_STRING "2010-01-07 17:02" diff --git a/src/files.c b/src/files.c index cd288bce..a969861e 100644 --- a/src/files.c +++ b/src/files.c @@ -4212,7 +4212,7 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level) LevelInfoType *header = &level_sp->header; int i, x, y; - level_sp->width = level->fieldx; + level_sp->width = level->fieldx; level_sp->height = level->fieldy; for (x = 0; x < level->fieldx; x++) @@ -4244,7 +4244,67 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level) header->InfotronsNeeded = level->gems_needed; - /* !!! ADD SPECIAL PORT DATABASE STUFF !!! */ + header->SpecialPortCount = 0; + + for (x = 0; x < level->fieldx; x++) for (y = 0; y < level->fieldy; y++) + { + boolean gravity_port_found = FALSE; + boolean gravity_port_valid = FALSE; + int gravity_port_flag; + int gravity_port_base_element; + int element = level->field[x][y]; + + if (element >= EL_SP_GRAVITY_ON_PORT_RIGHT && + element <= EL_SP_GRAVITY_ON_PORT_UP) + { + gravity_port_found = TRUE; + gravity_port_valid = TRUE; + gravity_port_flag = 1; + gravity_port_base_element = EL_SP_GRAVITY_ON_PORT_RIGHT; + } + else if (element >= EL_SP_GRAVITY_OFF_PORT_RIGHT && + element <= EL_SP_GRAVITY_OFF_PORT_UP) + { + gravity_port_found = TRUE; + gravity_port_valid = TRUE; + gravity_port_flag = 0; + gravity_port_base_element = EL_SP_GRAVITY_OFF_PORT_RIGHT; + } + else if (element >= EL_SP_GRAVITY_PORT_RIGHT && + element <= EL_SP_GRAVITY_PORT_UP) + { + /* change R'n'D style gravity inverting special port to normal port + (there are no gravity inverting ports in native Supaplex engine) */ + + gravity_port_found = TRUE; + gravity_port_valid = FALSE; + gravity_port_base_element = EL_SP_GRAVITY_PORT_RIGHT; + } + + if (gravity_port_found) + { + if (gravity_port_valid && + header->SpecialPortCount < SP_MAX_SPECIAL_PORTS) + { + SpecialPortType *port = &header->SpecialPort[header->SpecialPortCount]; + + port->PortLocation = (y * level->fieldx + x) * 2; + port->Gravity = gravity_port_flag; + + element += EL_SP_GRAVITY_PORT_RIGHT - gravity_port_base_element; + + header->SpecialPortCount++; + } + else + { + /* change special gravity port to normal port */ + + element += EL_SP_PORT_RIGHT - gravity_port_base_element; + } + + level_sp->playfield[x][y] = element - EL_SP_START; + } + } } void CopyNativeLevel_SP_to_RND(struct LevelInfo *level)