Skip to content

Commit

Permalink
Merge pull request #696 from Sparker95/development
Browse files Browse the repository at this point in the history
Fix main thread crash (Error in SensorGarrisonTargets)
  • Loading branch information
Sparker95 authored Aug 7, 2020
2 parents 82f208e + 45f82c1 commit ab2cba8
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ jobs:
- name: Get Release Info
run: |
$latest_release = (Invoke-WebRequest https://api.github.com/repos/${{ github.repository }}/releases | ConvertFrom-Json).Get(0)
$major, $minor = $latest_release.tag_name.replace('v','').split('.')
$versionSplit = $latest_release.tag_name.replace('v','').split('.')
$major = $versionSplit[0]
$minor = $versionSplit[1]
Set-Content -Path .\configs\majorVersion.hpp -Value $major -Force -NoNewline
Set-Content -Path .\configs\minorVersion.hpp -Value $minor -Force -NoNewline
$uploadurl = $latest_release.upload_url
Expand Down
2 changes: 1 addition & 1 deletion configs/minorVersion.hpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
47
48
13 changes: 7 additions & 6 deletions src/AI/Garrison/SensorGarrisonSound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,22 @@ CLASS("SensorGarrisonSound", "SensorGarrisonStimulatable")
// Check inside the critical section, or we have race condition
if !(isNull _hO) then {
pr _unit = GET_UNIT_FROM_OBJECT_HANDLE(_hO);
pr _hOpos = getPos _hO;
pr _distance = (getPos _hO) distance2D _garPos;
pr _inaccuracy = _distance*0.1; // We randomize the position a little, depending on how far the target is
pr _pos = [(_hOpos#0) + (random _inaccuracy) - 0.5*_inaccuracy, (_hOpos#1) + (random _inaccuracy) - 0.5*_inaccuracy, 0];
_ret = if (IS_OOP_OBJECT(_unit)) then {
pr _distance = (getPos _hO) distance2D _garPos;
pr _inaccuracy = _distance*0.1; // We randomize the position a little, depending on how far the target is
pr _hOpos = getPos _hO;
pr _pos = [(_hOpos#0) + (random _inaccuracy) - 0.5*_inaccuracy, (_hOpos#1) + (random _inaccuracy) - 0.5*_inaccuracy, 0];
pr _eff = GET_UNIT_EFFICIENCY_FROM_OBJECT_HANDLE(_hO);
pr _target = TARGET_NEW(_unit, 2.0, _pos, _dateNumber, +_eff);

OOP_INFO_1(" %1", _target);

// Return stimulus
_target;
} else {
pr __str = format ["unknown %1", _hO];
TARGET_NEW(__str, 2.0, _pos, _dateNumber, +(T_efficiency#T_INF#T_INF_rifleman));
pr _target = TARGET_NEW(__str, 2.0, _pos, _dateNumber, +(T_efficiency#T_INF#T_INF_rifleman));
OOP_INFO_1(" %1", _target);
_target;
};
};
};
Expand Down
3 changes: 3 additions & 0 deletions src/GameMode/GameModeBase.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ CLASS("GameModeBase", "MessageReceiverEx")

#ifdef RELEASE_BUILD
// Make a recursive dump of the last processed object
// Disabled for now, we don't use it anyway
/*
private _lastObject = GETV(_msgLoop, "lastObject");
if (IS_NULL_OBJECT(_lastObject)) then {
OOP_ERROR_0("Last processed object is null");
Expand All @@ -513,6 +515,7 @@ CLASS("GameModeBase", "MessageReceiverEx")
[_lastObject, 6] call OOP_objectCrashDump; // 6 is max depth
};
};
*/
#endif
FIX_LINE_NUMBERS()

Expand Down
9 changes: 9 additions & 0 deletions src/MessageLoopManagers/MessageLoopMainManager.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,19 @@ CLASS("MessageLoopMainManager", "MessageReceiverEx");
public METHOD(finishPlayerSpawn)
params [P_THISOBJECT, P_OBJECT("_playerObj"), P_SIDE("_playerSide"), P_ARRAY("_respawnPos")];

diag_log format ["finishPlayerSpawn: %1", _this];

pr _prevUnit = GET_UNIT_FROM_OBJECT_HANDLE(_playerObj);
if (!IS_NULL_OBJECT(_prevUnit)) then {
OOP_ERROR_1("finishPlayerSpawn: player object already has a unit: %1", _prevUnit);
};

// Create a new Unit and attach it to player
pr _args = [[], T_INF, T_INF_rifleman, -1, "", _playerObj];
pr _unit = NEW("Unit", _args);

diag_log format [" Created unit for player: %1, %2", _unit, GET_UNIT_FROM_OBJECT_HANDLE(_playerObj)];

// Add player's unit to the global garrison
pr _gar = CALLSM1("GameModeBase", "getPlayerGarrisonForSide", _playerSide);
CALLM1(_gar, "addUnit", _unit);
Expand Down
2 changes: 2 additions & 0 deletions src/Unit/EH_Respawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Executed in unscheduled when a unit respawns.

params ["_unit", "_corpse"];

OOP_INFO_1("EH_Respawn: %1", _this);

// make it possible to ace interact with the unit again
[objNull, _corpse] call ace_common_fnc_claim;

Expand Down
14 changes: 12 additions & 2 deletions src/Unit/Unit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,11 @@ CLASS("Unit", ["Storable" ARG "GOAP_Agent"])

// Set variables of the object
if (!isNull _hO) then {
pr _prevUnit = GET_UNIT_FROM_OBJECT_HANDLE(_hO);
if (!IS_NULL_OBJECT(_prevUnit)) then {
OOP_ERROR_2("initObjectVariables: unit already has a unit object attached to it: %1 %2", _hO, _prevUnit);
};

// Variable with a reference to Unit object
_hO setVariable [UNIT_VAR_NAME_STR, _thisObject, true]; // Global variable!
pr _cat = _data select UNIT_DATA_ID_CAT;
Expand Down Expand Up @@ -732,10 +737,12 @@ CLASS("Unit", ["Storable" ARG "GOAP_Agent"])
// Reset variables of the object
if (!isNull _hO) then {
// Variable with a reference to Unit object
_hO setVariable [UNIT_VAR_NAME_STR, nil];
// Let's not erase it to be safe, armas event handlers are very fucked up in MP game
// and I am afraid that a case like that could erase variable on an valid player object
_hO setVariable [UNIT_VAR_NAME_STR, nil, true];

// Variable with the efficiency vector of this unit
_hO setVariable [UNIT_EFFICIENCY_VAR_NAME_STR, nil];
//_hO setVariable [UNIT_EFFICIENCY_VAR_NAME_STR, nil];
};
ENDMETHOD;

Expand All @@ -753,6 +760,8 @@ CLASS("Unit", ["Storable" ARG "GOAP_Agent"])
pr _catID = _data select UNIT_DATA_ID_CAT;

// Respawned
/*
// I don't think we need it at all, do we?
if (isNil {_hO getVariable UNIT_EH_RESPAWN_STR}) then {
pr _ehid = [_hO, "Respawn", {
params ["_unit"];
Expand All @@ -765,6 +774,7 @@ CLASS("Unit", ["Storable" ARG "GOAP_Agent"])
}] call CBA_fnc_addBISEventHandler;
_hO setVariable [UNIT_EH_RESPAWN_STR, _ehid];
};
*/

// Rating (hopefully disabling the renegade system)
if (isNil {_hO getVariable UNIT_EH_HANDLE_RATING_STR}) then {
Expand Down

0 comments on commit ab2cba8

Please sign in to comment.