Skip to content

Commit

Permalink
fix warnings from AvaraTests run in Xcode
Browse files Browse the repository at this point in the history
Turned on sanitization options to help identify potential memory bugs.

Fixed null-pointer bugs for test runs (maybe causes hang??)
Added destructor to TestPlayerManager() to squelch another warning.
  • Loading branch information
tra committed Apr 28, 2024
1 parent f449086 commit b28e677
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Avara.xcodeproj/xcshareddata/xcschemes/AvaraTests.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableAddressSanitizer = "YES"
enableASanStackUseAfterReturn = "YES"
enableUBSanitizer = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -53,6 +54,18 @@
ReferencedContainer = "container:Avara.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
<AdditionalOption
key = "MallocScribble"
value = ""
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion src/game/CAvaraGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void CAvaraGame::IAvaraGame(CAvaraApp *theApp) {

nextPingTime = 0;

showNewHUD = gApplication->Get<bool>(kShowNewHUD);
showNewHUD = gApplication ? gApplication->Get<bool>(kShowNewHUD) : false;
// CalcGameRect();

// vg = AvaraVGContext();
Expand Down
2 changes: 1 addition & 1 deletion src/game/CNetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ void CNetManager::UpdateLocalConfig() {
? gApplication->Get<float>(kLatencyToleranceTag) / itsGame->fpsScale
: 0;
config.frameTime = itsGame->frameTime;
config.spawnOrder = gApplication->Get<short>(kSpawnOrder);
config.spawnOrder = gApplication ? gApplication->Get<short>(kSpawnOrder) : ksHybrid;
config.hullType = gApplication ? gApplication->Number(kHullTypeTag) : 0;
config.hullColor = gApplication
? ARGBColor::Parse(gApplication->String(kPlayerHullColorTag))
Expand Down
1 change: 1 addition & 0 deletions src/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TestPlayerManager : public CPlayerManager {
FunctionTable &ft = *(this->ft);
ft.down = ft.up = ft.held = ft.mouseDelta.h = ft.mouseDelta.v = ft.buttonStatus = ft.msgChar = 0;
}
~TestPlayerManager() {}
virtual CAbstractPlayer* GetPlayer() { return playa; }
virtual void SetPlayer(CAbstractPlayer* p) { playa = p; }
virtual short Slot() { return 0; }
Expand Down

0 comments on commit b28e677

Please sign in to comment.