Mario: support the new modifier object IDs in maploader
This commit is contained in:
parent
a01b6070f3
commit
45ac4dad64
@ -59,8 +59,10 @@ uint8_t combineAdditionalData( uint8_t id, uint8_t type ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MapObject parseBlock( std::ifstream &map_file ) {
|
MapObject parseBlock( std::ifstream &map_file ) {
|
||||||
uint8_t character_type = 0, character_id = 0, modifier_id = 0,
|
uint8_t character_type = 0;
|
||||||
modifier_data = 0;
|
uint8_t character_id = 0;
|
||||||
|
uint32_t modifier_id = 0;
|
||||||
|
uint8_t modifier_data = 0;
|
||||||
uint16_t wide_terrain = read16Bits( map_file );
|
uint16_t wide_terrain = read16Bits( map_file );
|
||||||
auto terrain = separateWideTerrain( wide_terrain );
|
auto terrain = separateWideTerrain( wide_terrain );
|
||||||
uint16_t terrain_id = terrain.first;
|
uint16_t terrain_id = terrain.first;
|
||||||
@ -72,7 +74,7 @@ MapObject parseBlock( std::ifstream &map_file ) {
|
|||||||
additional_data &= ~ADDITIONAL_IS_MOD;
|
additional_data &= ~ADDITIONAL_IS_MOD;
|
||||||
auto modifier = separateAdditionalData( additional_data );
|
auto modifier = separateAdditionalData( additional_data );
|
||||||
// TODO swap modifier id and data
|
// TODO swap modifier id and data
|
||||||
modifier_id = modifier.second;
|
modifier_id = modifier.second | 0x6000;
|
||||||
modifier_data = modifier.first;
|
modifier_data = modifier.first;
|
||||||
} else {
|
} else {
|
||||||
// character
|
// character
|
||||||
@ -163,6 +165,15 @@ void loadMap( std::shared_ptr< SDLPP::Scene > &scene,
|
|||||||
mario->setPos( i * BLOCK_SIZE,
|
mario->setPos( i * BLOCK_SIZE,
|
||||||
1 - ( 16 - j ) * BLOCK_SIZE );
|
1 - ( 16 - j ) * BLOCK_SIZE );
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
auto obj = createTerrainBlock(
|
||||||
|
block.getCharacterId(), block.getCharacterType(),
|
||||||
|
renderer, i, j, destructible, editor);
|
||||||
|
dynamic_cast< MarioBlock * >( obj.get() )->setTerrain( false );
|
||||||
|
if ( editor ) {
|
||||||
|
obj->getCollisions()[0]->setId( EDITOR_CHARACTER_ID );
|
||||||
|
}
|
||||||
|
scene->addObject(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( editor && block.hasModifier() ) {
|
if ( editor && block.hasModifier() ) {
|
||||||
@ -202,7 +213,8 @@ void saveMap( const std::string &file, std::vector< mapColumnType > &objects ) {
|
|||||||
additional_data = combineAdditionalData(block.getCharacterId(), block.getCharacterType());
|
additional_data = combineAdditionalData(block.getCharacterId(), block.getCharacterType());
|
||||||
} else if ( block.hasModifier() ) {
|
} else if ( block.hasModifier() ) {
|
||||||
// TODO seriously change order of id/data!!!
|
// TODO seriously change order of id/data!!!
|
||||||
additional_data = combineAdditionalData(block.getModifierData(), block.getModifierId());
|
// we have IDs like 0x600X but only X is useful data, the 0x6 at the beginning is to differentiate mods from characters
|
||||||
|
additional_data = combineAdditionalData(block.getModifierData(), block.getModifierId() & 0x000F);
|
||||||
additional_data |= ADDITIONAL_IS_MOD;
|
additional_data |= ADDITIONAL_IS_MOD;
|
||||||
}
|
}
|
||||||
if ( additional_data ) {
|
if ( additional_data ) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
MapObject::MapObject( uint16_t terrain_id, LandType::Value terrain_type,
|
MapObject::MapObject( uint16_t terrain_id, LandType::Value terrain_type,
|
||||||
uint8_t character_id, LandType::Value character_type,
|
uint8_t character_id, LandType::Value character_type,
|
||||||
uint8_t modifier_id, uint8_t modifier_data ) {
|
uint32_t modifier_id, uint8_t modifier_data ) {
|
||||||
setTerrain(terrain_id, terrain_type);
|
setTerrain(terrain_id, terrain_type);
|
||||||
if(character_id != 0)
|
if(character_id != 0)
|
||||||
setCharacter(character_id, character_type);
|
setCharacter(character_id, character_type);
|
||||||
@ -12,7 +12,7 @@ MapObject::MapObject( uint16_t terrain_id, LandType::Value terrain_type,
|
|||||||
|
|
||||||
MapObject::MapObject( uint16_t terrain_id, uint8_t terrain_type,
|
MapObject::MapObject( uint16_t terrain_id, uint8_t terrain_type,
|
||||||
uint8_t character_id, uint8_t character_type,
|
uint8_t character_id, uint8_t character_type,
|
||||||
uint8_t modifier_id, uint8_t modifier_data )
|
uint32_t modifier_id, uint8_t modifier_data )
|
||||||
: MapObject( terrain_id, static_cast< LandType::Value >( terrain_type ),
|
: MapObject( terrain_id, static_cast< LandType::Value >( terrain_type ),
|
||||||
character_id,
|
character_id,
|
||||||
static_cast< LandType::Value >( character_type ),
|
static_cast< LandType::Value >( character_type ),
|
||||||
@ -40,7 +40,7 @@ void MapObject::setCharacter( uint8_t id, uint8_t land_type ) {
|
|||||||
setCharacter( id, static_cast< LandType::Value >( land_type ) );
|
setCharacter( id, static_cast< LandType::Value >( land_type ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapObject::setModifier( uint8_t id, uint8_t data ) {
|
void MapObject::setModifier( uint32_t id, uint8_t data ) {
|
||||||
modifier_id = id;
|
modifier_id = id;
|
||||||
modifier_data = data;
|
modifier_data = data;
|
||||||
if(hasCharacter()) {
|
if(hasCharacter()) {
|
||||||
@ -81,7 +81,7 @@ uint8_t MapObject::getCharacterId() {
|
|||||||
return character_id;
|
return character_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t MapObject::getModifierId() {
|
uint32_t MapObject::getModifierId() {
|
||||||
return modifier_id;
|
return modifier_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,16 +7,16 @@ class MapObject {
|
|||||||
public:
|
public:
|
||||||
MapObject() = default;
|
MapObject() = default;
|
||||||
MapObject( uint16_t terrain_id, uint8_t terrain_type, uint8_t character_id,
|
MapObject( uint16_t terrain_id, uint8_t terrain_type, uint8_t character_id,
|
||||||
uint8_t character_type, uint8_t modifier_id,
|
uint8_t character_type, uint32_t modifier_id,
|
||||||
uint8_t modifier_data );
|
uint8_t modifier_data );
|
||||||
MapObject( uint16_t terrain_id, LandType::Value terrain_type,
|
MapObject( uint16_t terrain_id, LandType::Value terrain_type,
|
||||||
uint8_t character_id, LandType::Value character_type,
|
uint8_t character_id, LandType::Value character_type,
|
||||||
uint8_t modifier_id, uint8_t modifier_data );
|
uint32_t modifier_id, uint8_t modifier_data );
|
||||||
void setTerrain( uint16_t id, LandType::Value land_type );
|
void setTerrain( uint16_t id, LandType::Value land_type );
|
||||||
void setTerrain( uint16_t id, uint8_t land_type );
|
void setTerrain( uint16_t id, uint8_t land_type );
|
||||||
void setCharacter( uint8_t id, LandType::Value land_type );
|
void setCharacter( uint8_t id, LandType::Value land_type );
|
||||||
void setCharacter( uint8_t id, uint8_t land_type );
|
void setCharacter( uint8_t id, uint8_t land_type );
|
||||||
void setModifier( uint8_t id, uint8_t data );
|
void setModifier( uint32_t id, uint8_t data );
|
||||||
void unsetTerrain();
|
void unsetTerrain();
|
||||||
void unsetModifier();
|
void unsetModifier();
|
||||||
void unsetCharacter();
|
void unsetCharacter();
|
||||||
@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
uint16_t getTerrainId();
|
uint16_t getTerrainId();
|
||||||
uint8_t getCharacterId();
|
uint8_t getCharacterId();
|
||||||
uint8_t getModifierId();
|
uint32_t getModifierId();
|
||||||
LandType::Value getTerrainType();
|
LandType::Value getTerrainType();
|
||||||
LandType::Value getCharacterType();
|
LandType::Value getCharacterType();
|
||||||
uint8_t getModifierData();
|
uint8_t getModifierData();
|
||||||
@ -35,7 +35,7 @@ private:
|
|||||||
uint16_t terrain_id = 0;
|
uint16_t terrain_id = 0;
|
||||||
LandType::Value character_type = LandType::OVERWORLD;
|
LandType::Value character_type = LandType::OVERWORLD;
|
||||||
uint8_t character_id = 0;
|
uint8_t character_id = 0;
|
||||||
uint8_t modifier_id = 0;
|
uint32_t modifier_id = 0;
|
||||||
uint8_t modifier_data = 0;
|
uint8_t modifier_data = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user