Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map waypoint loading #1165

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/game/client/maputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include <algorithm>

#ifndef GAME_DLL
WaypointMap *g_waypoints;
MapCache *g_theMapCache;
WaypointMap *g_waypoints = nullptr;
MapCache *g_theMapCache = nullptr;
#endif

static std::vector<ICoord2D> s_boundaries;
Expand All @@ -45,7 +45,6 @@ static std::list<Coord3D> s_techPositions;
static unsigned int s_width = 0;
static unsigned int s_height = 0;
static int s_borderSize = 0;
static WaypointMap *s_waypoints = nullptr;
static int s_mapDX = 0;
static int s_mapDY = 0;

Expand Down Expand Up @@ -114,7 +113,7 @@ void WaypointMap::Update()
key_name.Format("Player_%d_Start", i);
it = g_waypoints->find(key_name);

if (it != g_waypoints->end()) {
if (it == g_waypoints->end()) {
break;
}

Expand Down Expand Up @@ -431,7 +430,7 @@ bool Parse_Object_Data_Chunk(DataChunkInput &input, DataChunkInfo *info, void *d

if (object->Get_Properties()->Get_Type(g_waypointIDKey) == Dict::DICT_INT) {
object->Set_Is_Waypoint();
(*s_waypoints)[object->Get_Waypoint_Name()] = loc;
(*g_waypoints)[object->Get_Waypoint_Name()] = loc;
} else if (object->Get_Thing_Template() != nullptr && object->Get_Thing_Template()->Is_KindOf(KINDOF_TECH_BUILDING)) {
s_techPositions.push_back(loc);
} else if (object->Get_Thing_Template() != nullptr) {
Expand Down Expand Up @@ -470,7 +469,7 @@ bool Load_Map(Utf8String name)

if (stream.Open(name_copy2)) {
DataChunkInput input(&stream);
s_waypoints = new WaypointMap();
g_waypoints = new WaypointMap();
input.Register_Parser("HeightMapData", Utf8String::s_emptyString, Parse_Size_Only_In_Chunk, nullptr);
input.Register_Parser("WorldInfo", Utf8String::s_emptyString, Parse_World_Dict_Data_Chunk, nullptr);
input.Register_Parser("ObjectsList", Utf8String::s_emptyString, Parse_Objects_Data_Chunk, nullptr);
Expand Down Expand Up @@ -528,9 +527,9 @@ unsigned int Calc_CRC(Utf8String dir, Utf8String name)

void Reset_Map()
{
if (s_waypoints != nullptr) {
delete s_waypoints;
s_waypoints = nullptr;
if (g_waypoints != nullptr) {
delete g_waypoints;
g_waypoints = nullptr;
}

s_techPositions.clear();
Expand Down
Loading