This one is big, but unless I missed something, should be all be
trivial.
scripted-diff with the following, then manually tweaked whatever needed:
```
if [ $# -ne 3 ]; then
echo "Usage: $0 '<pattern>' '<replacement>' '<filename>'"
exit 1
fi
pattern="$1"
replacement="$2"
filename="$3"
if [ ! -f "$filename" ]; then
echo "Error: File $filename does not exist."
exit 1
fi
sed -i '/'"$pattern"'/ {
:loop
$ !{
N
/'"$pattern"'.*\n.*#endif/ {
s/'"$pattern"'/'"$replacement"'/
s/#else/} else {/
s/#endif/}/
P
D
}
/'"$pattern"'/ b loop
}
}' "$filename"
echo "Replacement complete in $filename"
```
h/t to Grok2 for the sed command
Requires accompanying GameDir change.
Removed ItemFlag as an xml tag and added bitmask flags as their own individual tags. Makes modding easier when the flags can be modified without math in the xml files
simplified the previous commit, now no more need for a tag
when checking IsItemLegal for Food System, ontop of checking for foodpoints, now also check if is drug
as a result, as previously, all eatable food will be excluded without food system, but now only if it isn't a drug at the same time
and no more tag to check for that in items.xml needed
no food items if the food system is off
whether the item is exclusive is defined by tag in items.xml
replaced previous way of decision, which used Item[usItemIndex].foodtype > 0 as criteria
that also restricted dual use items (i.e. drugs that also have a foodtype, like coffee, etc.)
.editorconfig already enforces it but it's getting changed piecemeal in
every commit. just get it done with.
the script:
```
find . -type f -not -path "./.git/*" -not -path "./.vs/*" | while read -r file; do
isFile=$(file -0 "$file" | cut -d $'\0' -f2)
case "$isFile" in
(*text*)
echo "$file is text"
if [[ $(tail -c 1 "$file" | wc -l) -ne 1 ]]; then
echo "" >> "$file"
fi
;;
(*)
echo "file isn't text"
;;
esac
done
```
Some bloodcats during ambushes could have ubInsertionDirection with values > 100, which then causes endless looping in pathfinding algorithms as valid direction values range from 0 to 7
UseCreatureMusic( HostileZombiesPresent() ); was overriding the music mode set in PrepareCreaturesForBattle() when encountering crepitus or being in the creature caves, resulting in regular tense and battle music being played.
The more detailed error message that used to go only to Livelog.txt is now also displayed in the ingame error screen, providing more helpful error message to players when making bug reports/asking for help
Requires accompanying gameDir change.
MercOpinions.xml now only contains opinions that are not 0. A new tag with fields "id" and "modifier" are used instead of old ones that had 255 <Opinion%d> $value$ </Opinion%d> tags for all profiles.
Loading time of MercOpinions.xml went down from ~4.047 s to 0.011 s due to this change with default 1.13 VFS config.
A small cmd utility tool for converting existing MercOpinions.xml data into the new format is available at https://github.com/Asdow/JA2-ConvertXMLData/tree/master
reworking r9343
- the part about Food System is obsolete, already was happening in code prior to r9343
- the flags got removed and a boolean is used instead, allowing a simpler function for the remaining disease
- wether an item is considered exclusive to disease feature or not is decided by usage of tag in items.xml
reworking r9343
- no need for Foodsystem flag, restricting food items to food system was already part of the code prior to r9343 (in IsItemLegal by silversurfer)
- for disease system changed flag to boolean
- two new options in ja2options.ini
ALTERNATIVE IMP CREATION
- adds new additional backgrounds, exclusive to this option
- which IMP backgrounds will be available at selection is determined by previously made choices for skills, character traits and disablities
- if a tag in background is contradicting to content of skill/character/disability, it won't be shown at selection
- what's considered contradicting is based on what's been found in code for conntent of skill/character/disability
- i.e. HeatIntolerant adds a penalty for desert and tropical sectors, so don't show backgrounds that add bonus for those sectortypes instead
- a new tag <alt_impcreation, has been added to backgrounds for this as well
- if that tag is found, it will be considered as additional IMP background exclusive to the option
REDUCED IMP CREATION
- same as above, but this time only the new additional backgrounds will be avaialable at selection
- same rules for possible restrictions to be shown
ALTERNATIVE IMP CREATION is required for REDUCED IMP CREATION to work
For ja2options.ini, a new category, "Backgrounds" was created.
This will contain the two new options and the general option to enable backgrounds
Accompanying changes in gamedir:
INIEditorJA2Options.xml
ja2options.ini
backgrounds.xml
This check was preventing enemies from retreating into another sector if tactical AI retreat was enabled, leading into AI deadlock every time AI_ACTION_RUNAWAY was the decision.
* User center insertion point for merc arrival
instead of initial arrival gridno that is meant only for the very first helidrop arrival at the start of a game.
* Prevent possible nullptr dereference
Call PruneWorldItems() before sectorinfo gets written to the save file.
Resetting the SF_ITEM_TEMP_FILE_EXISTS would not transfer correctly into the save file.
* Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY
* Add direction utility function
We have a lot of places in the code that calculate direction based on center cell coordinates, but lack a utility function for it similar to other direction methods.
* Use utility function for calculating direction
* Use ConvertGridNoToCenterCellXY
* Use utility function for direction
* Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY
* Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY
* Remove CenterX & CenterY functions
Use ConvertGridNoToCenterCellXY instead
* Remove CenterX & CenterY calls from UB configuration
* Address review feedback
* Remove duplicate function
ConvertGridNoToCenterCellXY and ConvertMapPosToWorldTileCenter do the exact same thing
* Use PythSpacesAway instead of GetRangeFromGridNoDiff
Both functions calculate the same thing
* Remove GetRangeFromGridNoDiff
* Remove calls to abs()
The values end up being squared anyways making these unnecessary
* Face gear is shaded the same as a face
* Render continue button above icons and facegear
* Face gear rendered below "hatch" (inactivity overlay)
* Consistent naming
It is revealed, MOLLE things in 1.13 are configured in XMLs using both NAS and OAS (old attachment system) methods even if NAS is enabled in New Game Options. Given this, logic of SetAttachmentSlotsFlag() cannot be splitted onto NAS and OAS parts, and both Attachment[] and AttachmentPoints must be checked disregarding the NAS option.
AIMNAS with its ~50K elements in Attachment[] suffered of performance drop when MOLLE stuff is in the visible inventory. To resolve it the following is done:
* Introduce gMAXATTACHMENTS_READ with actual number of elements in Attachment[]; according refactoring.
* Introduce gMAXLAUNCHABLES_READ with actual number of elements in Launchable[]; according refactoring.
* Introduce std::multimap AttachmentBackmap for quick access to attachments using itemId as a key.
* Sort Attachment[] by attachmentIndex right after loading from XML. According order in XML is not needed anymore.
* Introduce FindAttachmentRange() for quick access to attachments using attachmentId as a key (binary search in Attachment[]).
In a few words, GetHelpTextForItemInLaptop(), ValidAttachment(), SetAttachmentSlotsFlag() were heavily optimized.