A remake of the classic Dune 2 - The Building of a Dynasty (by Westwood Studios) with several enhancements. Like: higher screenresolutions, zooming, multiselect, skirmish play, etc.
const char* toStringBuildTypeSpecificType(const eBuildType &buildType, const int &specificTypeId) {
std::cout << "ID " << specificTypeId << std::endl;
switch (buildType) {
case eBuildType::SPECIAL:
std::cout << "SPECIAL" << std::endl;
return sSpecialInfo[specificTypeId].description;
case eBuildType::UNIT:
return sUnitInfo[specificTypeId].name;
case eBuildType::STRUCTURE:
return sStructureInfo[specificTypeId].name;
case eBuildType::BULLET:
return sBulletInfo[specificTypeId].description;
case eBuildType::UPGRADE:
return sUpgradeInfo[specificTypeId].description;
case eBuildType::UNKNOWN:
return std::string("Unknown");
default:
assert(false && "Undefined buildType?");
break;
}
return "";
}
You shall not have specificTypeId=-1 and eBuildType::SPECIAL because you read after sSpecialInfo[specificTypeId].descriptionsSpecialInfo is a tab so -1 is an unauthorised index
but the program do it without crash !!!
I read the debug log:
4409|WARN|NONE|cGameEvent [type=GAME_EVENT_SPICE_BLOOM_SPAWNED], [entityType=SPECIAL], [entityId=-1], [entitySpecificType=-1 =], [isReinforce=false], [atCell=2891], [buildingListItem=nullptr] [originId=-1]|(logbook)
I see [entitySpecificType=-1 =] and the description is passed on trap !
I should read [entitySpecificType=-1 =DESCRIPTION_HERE]
description is a char[64]
On another branch, i changed description to be a std::string and no char[64] and it is a drama:
When specificTypeId=-1 and eBuildType::SPECIAL the program cannot read sSpecialInfo[specificTypeId].description
because -1 is an unauthorised index and the program crash.
It's logical.
Why on master branch, the program doesn't crash when I call a tab with index -1 ?
Who can help me to patch his insoluble problem for me ?
(where is the link about GAME_EVENT_SPICE_BLOOM_SPAWNED and entityType=SPECIAL not Unknown ?
in this function:
You shall not have
specificTypeId=-1
andeBuildType::SPECIAL
because you read aftersSpecialInfo[specificTypeId].description
sSpecialInfo
is a tab so -1 is an unauthorised indexbut the program do it without crash !!!
I read the debug log:
4409|WARN|NONE|cGameEvent [type=GAME_EVENT_SPICE_BLOOM_SPAWNED], [entityType=SPECIAL], [entityId=-1], [entitySpecificType=-1 =], [isReinforce=false], [atCell=2891], [buildingListItem=nullptr] [originId=-1]|(logbook)
I see
[entitySpecificType=-1 =]
and the description is passed on trap !I should read
[entitySpecificType=-1 =DESCRIPTION_HERE]
description is a
char[64]
On another branch, i changed description to be a
std::string
and nochar[64]
and it is a drama:When
specificTypeId=-1
andeBuildType::SPECIAL
the program cannot readsSpecialInfo[specificTypeId].description
because -1 is an unauthorised index and the program crash.It's logical.
Why on master branch, the program doesn't crash when I call a tab with index -1 ?
Who can help me to patch his insoluble problem for me ? (where is the link about
GAME_EVENT_SPICE_BLOOM_SPAWNED
and entityType=SPECIAL
notUnknown
?