-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map action 507 for printing a message with the remaining map objects #1266
base: develop
Are you sure you want to change the base?
Map action 507 for printing a message with the remaining map objects #1266
Conversation
Nightly build for this pull request:
This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is ready to be used as of now. Refer to review comments and compiler warnings.
// Multiplayer house index (Player@A - Player@H) | ||
param3 = pThis->Param3 - HouseClass::PlayerAtA; | ||
} | ||
else if (pThis->Param3 - 8997 == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if (pThis->Param3 - 8997 == 0) | |
else if (pThis->Param3 == 8997) |
// Obtain houses | ||
int param3 = pThis->Param3; | ||
|
||
if (pThis->Param3 - HouseClass::PlayerAtA >= 0 && pThis->Param3 - HouseClass::PlayerAtA < 8997) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (pThis->Param3 - HouseClass::PlayerAtA >= 0 && pThis->Param3 - HouseClass::PlayerAtA < 8997) | |
if (pThis->Param3 >= HouseClass::PlayerAtA && pThis->Param3 <= HouseClass::PlayerAtH) |
else if (pThis->Param3 > 8997) | ||
{ | ||
Debug::Log("Map action %d: Invalid house index '%d'. This action will be skipped.\n", (int)pThis->ActionKind, pThis->Param3); | ||
return true; | ||
} | ||
|
||
if (param3 >= 0) | ||
{ | ||
pHousesList.push_back(HouseClass::Array->GetItem(param3)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we have only 4 houses, but set this param to i.e. 6? Or 5000?
return true; | ||
// Example: | ||
// ID=ActionCount,[Action1],507,4,[CSFKey],[HouseIndex],[AIHousesLists Index],[AITargetTypes Index],[MesageDelay],A,[ActionX] | ||
std::vector<HouseClass*> pHousesList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a pointer, so it shouldn't have the p
prefix.
@@ -66,6 +67,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) | |||
|
|||
const char* sectionAITargetTypes = "AITargetTypes"; | |||
const char* sectionAIScriptsList = "AIScriptsList"; | |||
const char* sectionAIHousesList = "AIHousesList"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it called AIHousesList
when it lists house types and not houses, and got nothing to do with being AI controlled?
if (pTechno->Owner == pHouse) | ||
{ | ||
globalRemaining++; | ||
nRemaining++; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a break here as there can be only one owner of an object.
if (globalRemaining > 0) | ||
{ | ||
wchar_t strInteger[24] = { 0 }; | ||
swprintf_s(strInteger, L"%d", globalRemaining); | ||
wcscat_s(message, strInteger); | ||
textToShow = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there are no remaining objects, nothing will be printed. Is this intentional? If so, then it should be explicitly mentioned in the documentation.
if (technosRemaining[i] == 0) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the previous comment about skipping 0 objects.
if (listIdx >= 0) | ||
housesList = RulesExt::Global()->AIHousesLists.at(listIdx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if index is bigger than the number of elements?
- If `HouseIndex` is set `-1` then `[AIHousesListsIndex]` will be used as index of a list of countries in the `[AIHousesList]` section located in `rulesmd.ini`. If any map object match the ownership with one of the list it will be counted. | ||
- `[AITargetTypesIndex]` is the index of an entry in the `[AITargetTypes]` section located in `rulesmd.ini`. Each alive map object listed here will be counted. | ||
- If `[AITargetTypesIndex]` is negative this value will be evaluated as a positive index in `[AITargetTypesIndex]` but instead of printing a list of alive map objects and the respective count it will appear as an unique global count of all the alive map objects listed in `[AITargetTypes]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say I'm a fan of controlling behavior like that. IMO it's better to have multiple actions with different behavior and well defined parameters.
CSFKey
is mentioned (value0
) it will use the default header textRemaining:
.HouseIndex
points to any house index of the map. Multiplayer 4475-4482 & 8997 indexes are valid.HouseIndex
is set-1
then[AIHousesListsIndex]
will be used as index of a list of countries in the[AIHousesList]
section located inrulesmd.ini
. If any map object match the ownership with one of the list it will be counted.[AITargetTypesIndex]
is the index of an entry in the[AITargetTypes]
section located inrulesmd.ini
. Each alive map object listed here will be counted.[AITargetTypesIndex]
is negative this value will be evaluated as a positive index in[AITargetTypesIndex]
but instead of printing a list of alive map objects and the respective count it will appear as an unique global count of all the alive map objects listed in[AITargetTypes]
.MesageDelay
is the time (in minutes) of the message displayed. If the value is 0 then the duration of the message will be the defaultMesageDelay
value specified inrulesmd.ini
.[AITargetTypes]
contains more than 5 map objects then the first lines won't appear.In
mycampaign.map
:--- Example 1 ---
507,4,0,5,0,-39,30,A
If tehre are 7 SAM turrets of that house with index "5" then the result would look like "Remaining: 7".
--- Example 2 ---
507,4,0,5,0,39,0,A
MesageDelay
value will be the default specified inrulesmd.ini
.If there are 7 SAM turrets & 2 Laser defenses of that house with index "5" then the result would look like:
"Remaining:
SAM Turret: 7
Laser Turret: 2"