Fix player properties "name" and "ai" #4628
Comments
Forgon uploaded file patch file created with |
Forgon uploaded file patch file created with |
Forgon uploaded file patch file created with |
Forgon uploaded file test challenge |
Forgon uploaded file test ai |
Forgon uploaded file view of setup screen names before this patch for test challenge |
Forgon uploaded file view of setup screen names after this patch for test challenge |
Forgon uploaded file |
Forgon uploaded file |
Forgon uploaded file patch file created with |
Berserk Cyborg changed status from |
Berserk Cyborg changed owner from `` to |
Berserk Cyborg changed resolution from `` to |
Berserk Cyborg committed [18] In Warzone2100/warzone2100@18ec97b:
|
resolution_fixed
type_patch (an actual patch, not a request for one)
| by ForgonThe player properties "name" and "ai" are broken.
In One-Player Skirmish games (excluding challenges) and Multi Player games, AI players get "name" and "ai" properties assigned only if selected interactively through the widget system (see function 'displayPlayer()' in './src/multiint.cpp'), where the position of the chosen AI in a vector of known
skirmish AIs (set up by function 'readAIs()' in './src/multiint.cpp') determines the "ai" property. The displayed AI name is copied to the player's "name". Because "Nexus" is the first entry in that vector, it is the default AI with "ai" equal to '0' (see '/.src/multiint.cpp:732').
Otherwise, all AI players
Challenge games get all "name" values from their configuration files printed in the setup screen before the game starts, except for player 0 (the human player). All "ai" values given are set to 'AI_CUSTOM', i.e. '127'. Once the game starts, all "name" values are discarded through the variable 'nameOverrides' (see './src/multiint.cpp').
Ingame, a player without name usually still has a name displayed. AI players without "name" value
are addressed by their colour. If a "name" value exists, their colour and a dash are prepended to their string. In chat messages, all players without names are adressed as "Commander" (since
#4612). This is useful for tutorials and campaigns.
This patch fixes all those problems by guaranteeing that
The variable 'nameOverrides' is now removed, as is other bizarre code. To correctly display "name" and "ai" values before the setup screen appears, there are now ugly hacks into the function 'hostCampaign()' in './src/multiopt.cpp':
"ai" values from challenge JSON files to AI players but is only called after the game starts. A new
function 'setupChallengeAIs()' now performs that task early.
The attached files 'test.json' and 'custom.json' provide a test challenge where all effects of this patch can be observed. I could not correctly test custom AIs, i.e. AIs exclusively available for challenges, possibly because they are not implemented. There are 8 combinations of "ai" and "name", corresponding to player numbers in the challenge file:
Issue migrated from trac:4628 at 2022-04-16 12:46:18 -0700
The text was updated successfully, but these errors were encountered: