Skip to content

Commit f8c2bf1

Browse files
committed
Code review changes
Fixup bound logic issue and extern arrays.
1 parent c38b083 commit f8c2bf1

8 files changed

Lines changed: 30 additions & 22 deletions

File tree

src/game/client/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,7 @@ target_sources_grouped(
16681668
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.h
16691669
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.cpp
16701670
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.h
1671+
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_bits.cpp
16711672
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_bits.h
16721673
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_detpack.cpp
16731674
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_detpack.h

src/game/server/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@ target_sources_grouped(
15211521
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.h
15221522
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.cpp
15231523
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.h
1524+
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_bits.cpp
15241525
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_bits.h
15251526
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_detpack.cpp
15261527
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_detpack.h

src/game/shared/neo/neo_crosshair.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ extern int g_verbose;
1414
#include "mathlib/mathlib.h"
1515
#include "neo_serial.h"
1616

17+
const ENeoCrosshairWep MAP_WEAPON_TYPE_TO_XHAIR[WEP_TYPE__TOTAL] = {
18+
CROSSHAIR_WEP_NONE, // WEP_TYPE_NIL
19+
CROSSHAIR_WEP_NONE, // WEP_TYPE_THROWABLE
20+
CROSSHAIR_WEP_SECONDARY, // WEP_TYPE_PISTOL
21+
CROSSHAIR_WEP_DEFAULT, // WEP_TYPE_SMG
22+
CROSSHAIR_WEP_SHOTGUN, // WEP_TYPE_SHOTGUN
23+
CROSSHAIR_WEP_DEFAULT, // WEP_TYPE_RIFLE
24+
CROSSHAIR_WEP_DEFAULT, // WEP_TYPE_MACHINEGUN
25+
CROSSHAIR_WEP_NONE, // WEP_TYPE_SNIPER
26+
};
27+
1728
#ifdef CLIENT_DLL
1829
#include "neo_gamerules.h"
1930
#include "weapon_neobasecombatweapon.h"

src/game/shared/neo/neo_crosshair.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,7 @@ enum ENeoCrosshairWep
6767
CROSSHAIR_WEP__TOTAL,
6868
};
6969

70-
static const ENeoCrosshairWep MAP_WEAPON_TYPE_TO_XHAIR[WEP_TYPE__TOTAL] = {
71-
CROSSHAIR_WEP_NONE, // WEP_TYPE_NIL
72-
CROSSHAIR_WEP_NONE, // WEP_TYPE_THROWABLE
73-
CROSSHAIR_WEP_SECONDARY, // WEP_TYPE_PISTOL
74-
CROSSHAIR_WEP_DEFAULT, // WEP_TYPE_SMG
75-
CROSSHAIR_WEP_SHOTGUN, // WEP_TYPE_SHOTGUN
76-
CROSSHAIR_WEP_DEFAULT, // WEP_TYPE_RIFLE
77-
CROSSHAIR_WEP_DEFAULT, // WEP_TYPE_MACHINEGUN
78-
CROSSHAIR_WEP_NONE, // WEP_TYPE_SNIPER
79-
};
70+
extern const ENeoCrosshairWep MAP_WEAPON_TYPE_TO_XHAIR[WEP_TYPE__TOTAL];
8071

8172
enum NeoCrosshairWepFlag_
8273
{

src/game/shared/neo/neo_serial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum ESerialVariantType
2424
static void StrCatCh(char (&szMutStr)[NEO_XHAIR_SEQMAX], const char ch)
2525
{
2626
const int iSize = V_strlen(szMutStr);
27-
if (iSize < NEO_XHAIR_SEQMAX)
27+
if ((iSize + 1) < NEO_XHAIR_SEQMAX)
2828
{
2929
szMutStr[iSize] = ch;
3030
szMutStr[iSize + 1] = '\0';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "weapon_bits.h"
2+
3+
#define DEFINE_WEAPON_TYPE(_x1, _x2, _x3, weptype) weptype,
4+
#define DEFINE_WEAPON_TYPE_ALT(_x1, _x2, _x3, _x4, weptype) weptype,
5+
6+
const ENeoWeaponType NEO_WEAPON_TYPE[NEO_WIDX__TOTAL] = {
7+
WEP_TYPE_NIL, // 0 = invalid, set none
8+
FOR_LIST_WEAPONS(DEFINE_WEAPON_TYPE, DEFINE_WEAPON_TYPE_ALT)
9+
#ifdef INCLUDE_WEP_PBK
10+
WEP_TYPE_MACHINEGUN,
11+
#endif
12+
};
13+

src/game/shared/neo/weapons/weapon_bits.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,7 @@ enum NeoWepBits : NEO_WEP_BITS_UNDERLYING_TYPE
7373
#endif
7474
};
7575

76-
#define DEFINE_CROSSHAIR_TYPE(_x1, _x2, _x3, weptype) weptype,
77-
#define DEFINE_CROSSHAIR_TYPE_ALT(_x1, _x2, _x3, _x4, weptype) weptype,
78-
79-
static const ENeoWeaponType NEO_WEAPON_TYPE[NEO_WIDX__TOTAL] = {
80-
WEP_TYPE_NIL, // 0 = invalid, set none
81-
FOR_LIST_WEAPONS(DEFINE_CROSSHAIR_TYPE, DEFINE_CROSSHAIR_TYPE_ALT)
82-
#ifdef INCLUDE_WEP_PBK
83-
WEP_TYPE_MACHINEGUN,
84-
#endif
85-
};
76+
extern const ENeoWeaponType NEO_WEAPON_TYPE[NEO_WIDX__TOTAL];
8677

8778
// Some other related type safety checks also rely on this equaling zero.
8879
static_assert(NEO_WEP_INVALID == 0);

src/tests/test_neo_crosshair.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void TestSerial_LongestLength()
339339
char szExportSeq[NEO_XHAIR_SEQMAX];
340340
ExportCrosshair(&xhairInfo, szExportSeq);
341341
// Make sure it's not maxing out the string
342-
TEST_VERIFY(V_strlen(szExportSeq) < (NEO_XHAIR_SEQMAX - 1));
342+
TEST_VERIFY(V_strlen(szExportSeq) < (NEO_XHAIR_SEQMAX - 1 - 1));
343343
TEST_COMPARE_STR(szExportSeq, SERIAL_TEST_STR);
344344
}
345345

0 commit comments

Comments
 (0)