Home » MODDING HQ 1.13 » Flugente's Magika Workshop » New feature: individual militia
Re: New feature: individual militia[message #353133 is a reply to message #353107] Sat, 14 April 2018 17:32 Go to previous messageGo to previous message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
RunAwayScientist wrote on Thu, 12 April 2018 23:56
>does not return an ID if the profile does not exist. Does that compile?
Yes. It compiles and runs correctly. This is not good practice, I know, so perhaps you'd prefer a return null or 0? This function does not apparently require a return and terminates normally if no returned ID is provided. Your code is very robust.


This is bad. If we create an existing militia soldier by, say, loading tactical, we use
Soldier.usIndividualMilitiaID = GetIdOfUnusedIndividualMilitia( pCreateStruct->ubSoldierClass, SECTOR( pCreateStruct->sSectorX, pCreateStruct->sSectorY ) );

So if we do not find a profile, this militia now has usIndividualMilitiaID 0 which means no ID. This means that this guy has no profile, thus no data will be stored etc.. As a result the feature now only works partially. I get that creating additional profiles is bad, but not creating ones for those missing them is at least equally bad.

RunAwayScientist wrote on Thu, 12 April 2018 23:56

> Second, if we do not have a profile, we need to create one, otherwise militia would be without it. So...

Nope, this is not required. What ends up happening is that if there is a problem or bug, it *will* create a new militia. This new militia ID orphans the old militia ID. This is how we get duplicated militia with orphan militia IDs that cannot be removed from savegames or dismissed. They are 'ghost' or 'phantom' IDs sitting in a vector. The game counts their salaries and results in a doubling of daily expenses. They *can* be dismissed manually, but this is annoying for the end user. They also /cannot/ be dismissed after their linked actual militia dies or disbands, resulting in stuck 'phantom' militia IDs in the save file that cannot be removed no matter what you do.

I guess the easiest (while not satisfactory) solution would be to write a function that loops over all sectors, counts militia, compares that to the 'alive' profiles existing for that sector, and creates new ones where required or culls excessive ones (newest first). Not satisfactory at that doesn't cure the root of the problem, which is new profiles not always being created properly for whatever reason.

RunAwayScientist wrote on Thu, 12 April 2018 23:56

> As to the warnings...

Yes, I agree. This is good practice. However, a new variable should be used to measure the current computer clock time so that only *1* single debug message should be displayed every 30 minutes, or use in-game time for every day. This would cut back on the spam and still be a useful reminder to the player that they have unarmed militia.

For my games: I commonly smuggle in Kerberus militia into ports and docks and move them completely unarmed to reinforce current combat locations where I can give them equipment. This is how I encountered this issue.

Eh. You kinda want that warning instantly. Knowing that something went wrong in the battle I've just started is good. Knowing that something went wrong at some point today is not useful. I'll think of something.



I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.

Report message to a moderator

Captain

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message light45.png
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message thumbs26.png
Read Message
Read Message
Read Message
Read Message bug6.png
Read Message
Read Message bug6.png
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New feature: advanced repair/dirt system
Next Topic: New (unofficial) mercs: The Ryder twins (Mass Effect: Andromeda)
Goto Forum:
  


Current Time: Mon Dec 02 13:28:43 GMT+2 2024

Total time taken to generate the page: 0.02431 seconds