Skip to content

Commit 7599dcf

Browse files
committed
fixes
1 parent 3cbc376 commit 7599dcf

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

src/server/commands/command_cheats.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ namespace Commands {
128128
for (int i = 0; i < static_cast<int>(globals.numEntities); ++i) {
129129
gentity_t* e = &g_entities[i];
130130
if (e->inUse) {
131-
gi.Com_PrintFmt("%3i: %s\n", i, e->className);
131+
gi.Com_PrintFmt("{}: {}\n", i, e->className);
132132
}
133133
}
134134
gi.Client_Print(ent, PRINT_HIGH, "-------------------\n");
@@ -140,11 +140,11 @@ namespace Commands {
140140
for (int i = 0; i < static_cast<int>(globals.numEntities); ++i) {
141141
gentity_t* e = &g_entities[i];
142142
if (e->inUse && (e->svFlags & SVF_MONSTER)) {
143-
gi.Com_PrintFmt("%3i: %s at %.1f %.1f %.1f\n", i, e->className, e->s.origin[0], e->s.origin[1], e->s.origin[2]);
143+
gi.Com_PrintFmt("{}: {} at {}\n", i, e->className, e->s.origin);
144144
count++;
145145
}
146146
}
147-
gi.Com_PrintFmt("Total monsters: %i\n", count);
147+
gi.Com_PrintFmt("Total monsters: {}\n", count);
148148
gi.Client_Print(ent, PRINT_HIGH, "--------------------\n");
149149
}
150150

src/server/commands/command_client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,12 @@ Enables administrative permissions when the correct password is supplied.
341341

342342
default:
343343
// Unknown impulses silently ignored (classic Q1 feel), but a hint helps once.
344-
gi.LocClient_Print(ent, PRINT_LOW, "impulse %d ignored (supported: 1..8, 9, 10, 12, 21, 255)\n", n);
344+
gi.LocClient_Print(ent, PRINT_LOW, "impulse {} ignored (supported: 1..8, 9, 10, 12, 21, 255)\n", n);
345345
return;
346346
}
347347

348348
if (!handled && n >= 1 && n <= 8) {
349-
gi.LocClient_Print(ent, PRINT_LOW, "You do not have a valid weapon for impulse %d\n", n);
349+
gi.LocClient_Print(ent, PRINT_LOW, "You do not have a valid weapon for impulse {}\n", n);
350350
}
351351
}
352352

src/server/gameplay/g_client_cfg.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ void ClientConfigStore::SaveInternal(const std::string& playerID, int skillRatin
9292
Json::CharReaderBuilder builder;
9393
std::string errs;
9494
if (!Json::parseFromStream(builder, in, &cfg, &errs)) {
95-
gi_.Com_PrintFmt("%s: parse error in %s: %s\n", __FUNCTION__, path.c_str(), errs.c_str());
95+
gi_.Com_PrintFmt("{}: parse error in {}: {}\n", __FUNCTION__, path.c_str(), errs.c_str());
9696
cfg = Json::Value(Json::objectValue);
9797
}
9898
}
9999
else {
100-
gi_.Com_PrintFmt("%s: creating new player config for missing file %s\n", __FUNCTION__, path.c_str());
100+
gi_.Com_PrintFmt("{}: creating new player config for missing file {}\n", __FUNCTION__, path.c_str());
101101
}
102102
}
103103

@@ -270,13 +270,13 @@ void ClientConfigStore::SaveInternal(const std::string& playerID, int skillRatin
270270

271271
try {
272272
if (!EnsurePlayerConfigDirectory()) {
273-
gi_.Com_PrintFmt("%s: failed to ensure player config directory\n", __FUNCTION__);
273+
gi_.Com_PrintFmt("{}: failed to ensure player config directory\n", __FUNCTION__);
274274
return;
275275
}
276276

277277
std::ofstream out(path);
278278
if (!out.is_open()) {
279-
gi_.Com_PrintFmt("%s: failed to write %s\n", __FUNCTION__, path.c_str());
279+
gi_.Com_PrintFmt("{}: failed to write {}\n", __FUNCTION__, path.c_str());
280280
return;
281281
}
282282

@@ -286,10 +286,10 @@ void ClientConfigStore::SaveInternal(const std::string& playerID, int skillRatin
286286
writer->write(cfg, &out);
287287
out.close();
288288

289-
gi_.Com_PrintFmt("%s: saved updates for %s\n", __FUNCTION__, playerID.c_str());
289+
gi_.Com_PrintFmt("{}: saved updates for {}\n", __FUNCTION__, playerID.c_str());
290290
}
291291
catch (const std::exception& e) {
292-
gi_.Com_PrintFmt("%s: exception: %s\n", __FUNCTION__, e.what());
292+
gi_.Com_PrintFmt("{}: exception: {}\n", __FUNCTION__, e.what());
293293
}
294294
}
295295
/*

src/server/gameplay/g_spawn.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace {
7878
*/
7979
static std::string BuildMapEntityContext(const gentity_t* ent)
8080
{
81-
const char* map_name = level.mapName.empty() ? "<unknown>" : level.mapName.c_str();
81+
const char* map_name = level.mapName.empty() ? "<unknown>" : level.mapName.data();
8282
const int32_t ent_num = ent ? static_cast<int32_t>(ent - g_entities) : -1;
8383
const char* class_name = (ent && ent->className) ? ent->className : "<unset>";
8484
const char* model_name = (ent && ent->model) ? ent->model : "<unset>";
@@ -699,6 +699,9 @@ static const std::initializer_list<spawn_t> spawns = {
699699
worr::Logf(worr::LogLevel::Warn, "{}: null entity provided; skipping map fixes {}", __FUNCTION__, BuildMapEntityContext(ent));
700700
return;
701701
}
702+
if (!ent->inUse) {
703+
return;
704+
}
702705
if (!ent->className || !ent->model) {
703706
worr::Logf(worr::LogLevel::Warn, "{}: missing data; skipping map fixes {}", __FUNCTION__, BuildMapEntityContext(ent));
704707
return;

src/server/gameplay/g_spawn_points.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,9 +1074,15 @@ bool SelectSpawnPoint(gentity_t* ent, Vector3& origin, Vector3& angles, bool for
10741074
return false;
10751075
}
10761076

1077+
// Validate spot one more time before dereferencing
1078+
if (!spot || !spot->inUse) {
1079+
gi.Com_PrintFmt("{}: selected spawn point is invalid\n", __FUNCTION__);
1080+
return false;
1081+
}
1082+
10771083
// Place slightly above pad if allowed
10781084
const float zlift = match_allowSpawnPads->integer ? 9.0f : 1.0f;
1079-
origin = spot->s.origin + Vector3{ 0.0f, 0.0f, zlift };
1085+
origin = spot->s.origin + gvec3_t{ 0.0f, 0.0f, zlift };
10801086
angles = spot->s.angles;
10811087

10821088
// Ensure no roll; optionally zero pitch if desired

src/server/menu/menu_page_setup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct MatchSetupState {
2828

2929
static void FinishMatchSetup(gentity_t* ent, MatchSetupState* state) {
3030
// Example: Apply config and broadcast
31-
gi.Com_PrintFmt("Match setup complete: gametype=%s modifier=%s players=%d length=%s type=%s bestof=%s\n",
31+
gi.Com_PrintFmt("Match setup complete: gametype={} modifier={} players={} length={} type={} bestof={}\n",
3232
state->gametype.c_str(), state->modifier.c_str(), state->maxPlayers,
3333
state->length.c_str(), state->type.c_str(), state->bestOf.c_str());
3434

@@ -133,7 +133,7 @@ static void OpenSetupMaxPlayersMenu(gentity_t* ent, MatchSetupState* state) {
133133
MenuBuilder b;
134134
b.add("Max Players", MenuAlign::Center).spacer();
135135
for (int count : {2, 4, 8, 16}) {
136-
b.add(G_Fmt("%d", count).data(), MenuAlign::Left, [=](gentity_t* e, Menu& m) {
136+
b.add(G_Fmt("{}", count).data(), MenuAlign::Left, [=](gentity_t* e, Menu& m) {
137137
state->maxPlayers = count;
138138
OpenSetupMatchLengthMenu(e, state);
139139
});

0 commit comments

Comments
 (0)