Skip to content

Commit

Permalink
unknown realm defined in startlocations now stops starting the core
Browse files Browse the repository at this point in the history
  • Loading branch information
turleypol committed Mar 3, 2024
1 parent 7627e3d commit 9f046ff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
14 changes: 3 additions & 11 deletions pol-core/pol/create.cpp
Expand Up @@ -317,9 +317,7 @@ void ClientCreateChar( Network::Client* client, PKTIN_00* msg )
chr->color = cfBEu16( msg->SkinColor );
chr->truecolor = chr->color;

Pos3d coord = gamestate.startlocations[msg->StartIndex]->select_coordinate();
Realms::Realm* realm = gamestate.startlocations[msg->StartIndex]->realm;
chr->setposition( Pos4d( coord, realm ) );
chr->setposition( gamestate.startlocations[msg->StartIndex]->select_coordinate() );
chr->facing = Core::FACING_W;
chr->position_changed();

Expand Down Expand Up @@ -661,10 +659,7 @@ void ClientCreateCharKR( Network::Client* client, PKTIN_8D* msg )
chr->color = cfBEu16( msg->skin_color );
chr->truecolor = chr->color;

Pos3d coord = gamestate.startlocations[0]->select_coordinate();
Realms::Realm* realm = gamestate.startlocations[0]->realm;

chr->setposition( Pos4d( coord, realm ) );
chr->setposition( gamestate.startlocations[0]->select_coordinate() );
chr->position_changed();
chr->facing = Core::FACING_W;

Expand Down Expand Up @@ -1041,10 +1036,7 @@ void ClientCreateChar70160( Network::Client* client, PKTIN_F8* msg )
chr->color = cfBEu16( msg->SkinColor );
chr->truecolor = chr->color;

Pos3d coord = gamestate.startlocations[msg->StartIndex]->select_coordinate();
Realms::Realm* realm = gamestate.startlocations[msg->StartIndex]->realm;

chr->setposition( Pos4d( coord, realm ) );
chr->setposition( gamestate.startlocations[msg->StartIndex]->select_coordinate() );
chr->position_changed();
chr->facing = Core::FACING_W;

Expand Down
4 changes: 2 additions & 2 deletions pol-core/pol/startloc.cpp
Expand Up @@ -12,11 +12,11 @@ namespace Pol
{
namespace Core
{
Pos3d StartingLocation::select_coordinate() const
Pos4d StartingLocation::select_coordinate() const
{
int sidx = Clib::random_int( static_cast<int>( coords.size() - 1 ) );

return coords[sidx];
return Pos4d( coords[sidx], realm );
}

size_t StartingLocation::estimateSize() const
Expand Down
2 changes: 1 addition & 1 deletion pol-core/pol/startloc.h
Expand Up @@ -35,7 +35,7 @@ class StartingLocation
*/
std::vector<Pos3d> coords;

Pos3d select_coordinate() const;
Pos4d select_coordinate() const;
size_t estimateSize() const;
};
} // namespace Core
Expand Down
16 changes: 12 additions & 4 deletions pol-core/pol/uimport.cpp
Expand Up @@ -1298,16 +1298,24 @@ void read_starting_locations()
loc->desc = elem.remove_string( "DESCRIPTION" );
loc->mapid = elem.remove_ushort( "MAPID", 0 );
loc->cliloc_desc = elem.remove_unsigned( "CLILOC", 1075072 );
loc->realm = find_realm( elem.remove_string( "REALM", "britannia" ) );

auto realmstr = elem.remove_string( "REALM", "britannia" );
loc->realm = find_realm( realmstr );
if ( !loc->realm )
{
ERROR_PRINTLN( "Unknown realm in startloc.cfg: '{}' for city {}, description {}", realmstr,
loc->city, loc->desc );
throw std::runtime_error( "Configuration file error in startloc.cfg." );
}
std::string coord;
while ( elem.remove_prop( "Coordinate", &coord ) )
{
int x, y, z;
if ( sscanf( coord.c_str(), "%d,%d,%d", &x, &y, &z ) == 3 )
{
loc->coords.push_back(
Pos3d( static_cast<u16>( x ), static_cast<u16>( y ), static_cast<s8>( z ) ) );
auto pos = Pos3d( Clib::clamp_convert<u16>( x ), Clib::clamp_convert<u16>( y ),
Clib::clamp_convert<s8>( z ) );
pos.crop( loc->realm );
loc->coords.emplace_back( std::move( pos ) );
}
else
{
Expand Down

0 comments on commit 9f046ff

Please sign in to comment.