mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
Modify SoldierID constructor to prevent invalid valuels
This commit is contained in:
@@ -388,7 +388,11 @@ typedef struct SoldierID
|
||||
inline operator UINT16() const { return i; }
|
||||
SoldierID(const UINT16 val = 0)
|
||||
: i(val)
|
||||
{}
|
||||
{
|
||||
// Limit the maximum value to TOTAL_SOLDIERS. Anything beyond that is invalid
|
||||
if ( i > TOTAL_SOLDIERS )
|
||||
i = TOTAL_SOLDIERS;
|
||||
}
|
||||
|
||||
SOLDIERTYPE* operator->() { return MercPtrs[i]; }
|
||||
const SOLDIERTYPE* operator->() const { return MercPtrs[i]; }
|
||||
|
||||
Reference in New Issue
Block a user