Skip to content

Commit c566396

Browse files
committed
Address some compiler warnings
1 parent 4391689 commit c566396

File tree

11 files changed

+69
-82
lines changed

11 files changed

+69
-82
lines changed

client/sdl/i_input_sdl20.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,7 @@ void ISDL20InputSubsystem::shutdownKeyboard(int id)
912912
std::vector<IInputDeviceInfo> ISDL20InputSubsystem::getMouseDevices() const
913913
{
914914
std::vector<IInputDeviceInfo> devices;
915-
devices.push_back(IInputDeviceInfo());
916-
IInputDeviceInfo& sdl_device_info = devices.back();
915+
IInputDeviceInfo& sdl_device_info = devices.emplace_back();
917916
sdl_device_info.mId = 0;
918917
sdl_device_info.mDeviceName = "SDL 2.0 mouse";
919918
return devices;
@@ -970,8 +969,7 @@ std::vector<IInputDeviceInfo> ISDL20InputSubsystem::getJoystickDevices() const
970969
std::vector<IInputDeviceInfo> devices;
971970
for (int i = 0; i < SDL_NumJoysticks(); i++)
972971
{
973-
devices.push_back(IInputDeviceInfo());
974-
IInputDeviceInfo& device_info = devices.back();
972+
IInputDeviceInfo& device_info = devices.emplace_back();
975973
device_info.mId = i;
976974
const char* name = SDL_GameControllerNameForIndex(i);
977975
device_info.mDeviceName = fmt::format("SDL 2.0 joystick ({})", name ? name : "unknown");

client/src/s_sound.cpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,16 @@ int S_CalculateSoundPriority(const fixed_t* pt, int channel, int attenuation)
560560
return priority;
561561
}
562562

563-
static int ResolveSound(int soundid)
563+
static size_t ResolveSound(size_t soundid)
564564
{
565565
const sfxinfo_t& sfx = S_sfx[soundid];
566566

567567
if (sfx.israndom)
568568
{
569569
while (S_sfx[soundid].israndom)
570570
{
571-
std::vector<int>& list = S_rnd[soundid];
572-
soundid = list[P_Random() % static_cast<int>(list.size())];
571+
std::vector<size_t>& list = S_rnd[soundid];
572+
soundid = list[P_Random() % list.size()];
573573
}
574574
return soundid;
575575
}
@@ -593,15 +593,15 @@ static void S_StartSound(fixed_t* pt, fixed_t x, fixed_t y, int channel,
593593
return;
594594

595595
// check for bogus sound #
596-
if (sfx_id < 1 || sfx_id > static_cast<int>(S_sfx.size()) - 1)
596+
if (sfx_id < 0 || sfx_id > static_cast<int>(S_sfx.size()) - 1)
597597
{
598598
DPrintf("Bad sfx #: %d\n", sfx_id);
599599
return;
600600
}
601601

602602
sfxinfo_t* sfxinfo = &S_sfx[sfx_id];
603603

604-
while (sfxinfo->link != static_cast<int>(sfxinfo_t::NO_LINK))
604+
while (sfxinfo->link != static_cast<size_t>(sfxinfo_t::NO_LINK))
605605
{
606606
sfx_id = ResolveSound(sfxinfo->link);
607607
sfxinfo = &S_sfx[sfx_id];
@@ -610,7 +610,7 @@ static void S_StartSound(fixed_t* pt, fixed_t x, fixed_t y, int channel,
610610
if (!sfxinfo->data)
611611
{
612612
I_LoadSound(sfxinfo);
613-
while (sfxinfo->link != static_cast<int>(sfxinfo_t::NO_LINK))
613+
while (sfxinfo->link != static_cast<size_t>(sfxinfo_t::NO_LINK))
614614
{
615615
sfx_id = ResolveSound(sfxinfo->link);
616616
sfxinfo = &S_sfx[sfx_id];
@@ -1202,7 +1202,7 @@ int S_FindSoundByLump(int lump)
12021202
return -1;
12031203
}
12041204

1205-
int S_AddSoundLump(const char *logicalname, int lump)
1205+
size_t S_AddSoundLump(const char *logicalname, int lump)
12061206
{
12071207
sfxinfo_t& new_sfx = S_sfx.emplace_back();
12081208

@@ -1220,7 +1220,7 @@ void S_ClearSoundLumps()
12201220
S_rnd.clear();
12211221
}
12221222

1223-
int FindSoundNoHash(const char* logicalname)
1223+
size_t FindSoundNoHash(const char* logicalname)
12241224
{
12251225
for (size_t i = 0; i < S_sfx.size(); i++)
12261226
if (iequals(logicalname, S_sfx[i].name))
@@ -1229,24 +1229,24 @@ int FindSoundNoHash(const char* logicalname)
12291229
return S_sfx.size();
12301230
}
12311231

1232-
int FindSoundTentative(const char* name)
1232+
size_t FindSoundTentative(const char* name)
12331233
{
1234-
int id = FindSoundNoHash(name);
1235-
if (id == static_cast<int>(S_sfx.size()))
1234+
size_t id = FindSoundNoHash(name);
1235+
if (id == S_sfx.size())
12361236
{
12371237
id = S_AddSoundLump(name, -1);
12381238
}
12391239
return id;
12401240
}
12411241

1242-
int S_AddSound(const char *logicalname, const char *lumpname)
1242+
size_t S_AddSound(const char *logicalname, const char *lumpname)
12431243
{
1244-
int sfxid = FindSoundNoHash(logicalname);
1244+
size_t sfxid = FindSoundNoHash(logicalname);
12451245

12461246
const int lump = lumpname ? W_CheckNumForName(lumpname) : -1;
12471247

12481248
// Otherwise, prepare a new one.
1249-
if (sfxid != static_cast<int>(S_sfx.size()))
1249+
if (sfxid != S_sfx.size())
12501250
{
12511251
sfxinfo_t& sfx = S_sfx[sfxid];
12521252

@@ -1264,7 +1264,7 @@ int S_AddSound(const char *logicalname, const char *lumpname)
12641264
return sfxid;
12651265
}
12661266

1267-
void S_AddRandomSound(int owner, std::vector<int>& list)
1267+
void S_AddRandomSound(size_t owner, std::vector<size_t>& list)
12681268
{
12691269
S_rnd[owner] = list;
12701270
S_sfx[owner].link = owner;
@@ -1395,22 +1395,22 @@ void S_ParseSndInfo()
13951395
else if (os.compareTokenNoCase("alias"))
13961396
{
13971397
os.mustScan();
1398-
const int sfxfrom = S_AddSound(os.getToken().c_str(), NULL);
1398+
const size_t sfxfrom = S_AddSound(os.getToken().c_str(), NULL);
13991399
os.mustScan();
14001400
S_sfx[sfxfrom].link = FindSoundTentative(os.getToken().c_str());
14011401
}
14021402
else if (os.compareTokenNoCase("random"))
14031403
{
1404-
std::vector<int> list;
1404+
std::vector<size_t> list;
14051405

14061406
os.mustScan();
1407-
const int owner = S_AddSound(os.getToken().c_str(), NULL);
1407+
const size_t owner = S_AddSound(os.getToken().c_str(), NULL);
14081408

14091409
os.mustScan();
14101410
os.assertTokenIs("{");
14111411
while (os.scan() && !os.compareToken("}"))
14121412
{
1413-
const int sfxto = FindSoundTentative(os.getToken().c_str());
1413+
const size_t sfxto = FindSoundTentative(os.getToken().c_str());
14141414

14151415
if (owner == sfxto)
14161416
{

common/g_level.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ void LevelInfos::clearSnapshots()
116116
// Add a new levelinfo and return it by reference
117117
level_pwad_info_t& LevelInfos::create()
118118
{
119-
m_infos.emplace_back();
120-
return m_infos.back();
119+
return m_infos.emplace_back();
121120
}
122121

123122
// Find a levelinfo by mapname
@@ -239,8 +238,7 @@ void ClusterInfos::clear()
239238
// Add a new levelinfo and return it by reference
240239
cluster_info_t& ClusterInfos::create()
241240
{
242-
m_infos.emplace_back();
243-
return m_infos.back();
241+
return m_infos.emplace_back();
244242
}
245243

246244
// Find a clusterinfo by mapname

common/g_mapinfo.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -877,16 +877,14 @@ void MIType_Map07Special(OScanner& os, bool newStyleMapInfo, void* data, unsigne
877877
*static_cast<std::vector<bossaction_t>*>(data);
878878

879879
// mancubus
880-
bossactionvector.emplace_back();
881-
bossaction_t& mancaction = bossactionvector.back();
880+
bossaction_t& mancaction = bossactionvector.emplace_back();
882881

883882
mancaction.type = MT_FATSO;
884883
mancaction.special = 23;
885884
mancaction.tag = 666;
886885

887886
// arachnotron
888-
bossactionvector.emplace_back();
889-
bossaction_t& arachnoaction = bossactionvector.back();
887+
bossaction_t& arachnoaction = bossactionvector.emplace_back();
890888

891889
arachnoaction.type = MT_BABY;
892890
arachnoaction.special = 30;
@@ -956,8 +954,7 @@ void MIType_SpecialAction_ExitLevel(OScanner& os, bool newStyleMapInfo, void* da
956954
}
957955
}
958956

959-
bossactionvector.emplace_back();
960-
bossaction_t& action = bossactionvector.back();
957+
bossaction_t& action = bossactionvector.emplace_back();
961958
action.special = 11;
962959
action.tag = 0;
963960
}
@@ -978,8 +975,7 @@ void MIType_SpecialAction_OpenDoor(OScanner& os, bool newStyleMapInfo, void* dat
978975
}
979976
}
980977

981-
bossactionvector.emplace_back();
982-
bossaction_t& action = bossactionvector.back();
978+
bossaction_t& action = bossactionvector.emplace_back();
983979
action.special = 29;
984980
action.tag = 666;
985981
}
@@ -1000,8 +996,7 @@ void MIType_SpecialAction_LowerFloor(OScanner& os, bool newStyleMapInfo, void* d
1000996
}
1001997
}
1002998

1003-
bossactionvector.emplace_back();
1004-
bossaction_t& action = bossactionvector.back();
999+
bossaction_t& action = bossactionvector.emplace_back();
10051000
action.special = 23;
10061001
action.tag = 666;
10071002
}

common/p_spec.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ void P_AddMovingCeiling(sector_t *sector)
264264
}
265265
else
266266
{
267-
movingsectors.emplace_back();
268-
movesec = &(movingsectors.back());
267+
movesec = &(movingsectors.emplace_back());
269268
}
270269

271270
movesec->sector = sector;
@@ -299,8 +298,7 @@ void P_AddMovingFloor(sector_t *sector)
299298
}
300299
else
301300
{
302-
movingsectors.emplace_back();
303-
movesec = &(movingsectors.back());
301+
movesec = &(movingsectors.emplace_back());
304302
}
305303

306304
movesec->sector = sector;

common/p_unlag.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void Unlag::registerPlayer(byte player_id)
373373
if (!validplayer(idplayer(player_id)))
374374
return;
375375

376-
player_history.push_back(PlayerHistoryRecord());
376+
player_history.emplace_back();
377377
player_history.back().player_id = player_id;
378378
player_history.back().history_size = 0;
379379
player_history.back().changed_flags = false;

common/s_sound.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct sfxinfo_struct
4545
unsigned looping; // Looping sample handle
4646
void* data;
4747

48-
int link;
48+
size_t link;
4949
enum { NO_LINK = 0xffffffff };
5050

5151
int lumpnum; // lump number of sfx
@@ -60,7 +60,7 @@ struct sfxinfo_struct
6060
inline std::vector<sfxinfo_t> S_sfx;
6161

6262
// map of every sound id for sounds that have randomized variants
63-
inline std::map<int, std::vector<int>> S_rnd;
63+
inline std::map<size_t, std::vector<size_t>> S_rnd;
6464

6565
// Initializes sound stuff, including volume
6666
// Sets channels, SFX and music volume,
@@ -166,9 +166,9 @@ void S_ParseSndInfo();
166166
void S_HashSounds();
167167
int S_FindSound(const char* logicalname);
168168
int S_FindSoundByLump(int lump);
169-
int S_AddSound(const char* logicalname, const char* lumpname); // Add sound by lumpname
170-
int S_AddSoundLump(char* logicalname, int lump); // Add sound by lump index
171-
void S_AddRandomSound(int owner, std::vector<int>& list);
169+
size_t S_AddSound(const char* logicalname, const char* lumpname); // Add sound by lumpname
170+
size_t S_AddSoundLump(char* logicalname, int lump); // Add sound by lump index
171+
void S_AddRandomSound(size_t owner, std::vector<size_t>& list);
172172
void S_ClearSoundLumps();
173173

174174
void UV_SoundAvoidPlayer(AActor* mo, byte channel, const char* name, byte attenuation);

server/src/s_sound.cpp

+14-15
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,9 @@ int S_FindSoundByLump(int lump)
264264
return -1;
265265
}
266266

267-
int S_AddSoundLump(const char *logicalname, int lump)
267+
size_t S_AddSoundLump(const char *logicalname, int lump)
268268
{
269-
S_sfx.emplace_back();
270-
sfxinfo_t& new_sfx = S_sfx.back();
269+
sfxinfo_t& new_sfx = S_sfx.emplace_back();
271270

272271
// logicalname MUST be < MAX_SNDNAME chars long
273272
strcpy(new_sfx.name, logicalname);
@@ -283,7 +282,7 @@ void S_ClearSoundLumps()
283282
S_rnd.clear();
284283
}
285284

286-
int FindSoundNoHash(const char* logicalname)
285+
size_t FindSoundNoHash(const char* logicalname)
287286
{
288287
for (size_t i = 0; i < S_sfx.size(); i++)
289288
if (iequals(logicalname, S_sfx[i].name))
@@ -292,24 +291,24 @@ int FindSoundNoHash(const char* logicalname)
292291
return S_sfx.size();
293292
}
294293

295-
int FindSoundTentative(const char* name)
294+
size_t FindSoundTentative(const char* name)
296295
{
297-
int id = FindSoundNoHash(name);
298-
if (id == static_cast<int>(S_sfx.size()))
296+
size_t id = FindSoundNoHash(name);
297+
if (id == S_sfx.size())
299298
{
300299
id = S_AddSoundLump(name, -1);
301300
}
302301
return id;
303302
}
304303

305-
int S_AddSound(const char *logicalname, const char *lumpname)
304+
size_t S_AddSound(const char *logicalname, const char *lumpname)
306305
{
307-
int sfxid = FindSoundNoHash(logicalname);
306+
size_t sfxid = FindSoundNoHash(logicalname);
308307

309308
const int lump = lumpname ? W_CheckNumForName(lumpname) : -1;
310309

311310
// Otherwise, prepare a new one.
312-
if (sfxid != static_cast<int>(S_sfx.size()))
311+
if (sfxid != S_sfx.size())
313312
{
314313
sfxinfo_t& sfx = S_sfx[sfxid];
315314

@@ -327,7 +326,7 @@ int S_AddSound(const char *logicalname, const char *lumpname)
327326
return sfxid;
328327
}
329328

330-
void S_AddRandomSound(int owner, std::vector<int>& list)
329+
void S_AddRandomSound(size_t owner, std::vector<size_t>& list)
331330
{
332331
S_rnd[owner] = list;
333332
S_sfx[owner].link = owner;
@@ -460,22 +459,22 @@ void S_ParseSndInfo()
460459
else if (os.compareTokenNoCase("alias"))
461460
{
462461
os.mustScan();
463-
const int sfxfrom = S_AddSound(os.getToken().c_str(), NULL);
462+
const size_t sfxfrom = S_AddSound(os.getToken().c_str(), NULL);
464463
os.mustScan();
465464
S_sfx[sfxfrom].link = FindSoundTentative(os.getToken().c_str());
466465
}
467466
else if (os.compareTokenNoCase("random"))
468467
{
469-
std::vector<int> list;
468+
std::vector<size_t> list;
470469

471470
os.mustScan();
472-
const int owner = S_AddSound(os.getToken().c_str(), NULL);
471+
const size_t owner = S_AddSound(os.getToken().c_str(), NULL);
473472

474473
os.mustScan();
475474
os.assertTokenIs("{");
476475
while (os.scan() && !os.compareToken("}"))
477476
{
478-
const int sfxto = FindSoundTentative(os.getToken().c_str());
477+
const size_t sfxto = FindSoundTentative(os.getToken().c_str());
479478

480479
if (owner == sfxto)
481480
{

server/src/sv_main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ Players::iterator SV_GetFreeClient(void)
515515
free_player_ids.insert(i);
516516
}
517517

518-
players.emplace_back();
519-
players.back().playerstate = PST_CONTACT;
518+
players.emplace_back().playerstate = PST_CONTACT;
520519

521520
// generate player id
522521
std::set<byte>::iterator id = free_player_ids.begin();

0 commit comments

Comments
 (0)