CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
576 stars 85 forks source link

Citizen not found error #1067

Closed meda22 closed 3 years ago

meda22 commented 3 years ago

Describe the problem

I see a lot of errors with "Citizen not found" in my output.log ... in example logs, there are only few of them just after game load - but when longer game session, then more of these errors appear.

Steps to reproduce

There are not any specific steps to reproduce. Problem occurs right after game loading...

Log files

output.log - https://drive.google.com/file/d/12jmHLmVAVqJQaCcBGuYNZD6dX5UNTW8y/view?usp=sharing TMPE.log - https://drive.google.com/file/d/1TETBqmlyCeMfFM6cs857F4GWV5E8f8-6/view?usp=sharing

Savegame

Save game: https://steamcommunity.com/sharedfiles/filedetails/?id=2441219872

Thanks for help!

meda22 commented 3 years ago

I made few more tests and it seems that it is connected to walking tours and sightseeing bus tours - when I remove them, I don't get any errors with "Citizen not found". Can it be somehow connected to this issue - even though it is from old repo? https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/223 (with that difference that it is not only walking tours but sightseeing bus tours too).

meda22 commented 3 years ago

So I made yet more tests - with clean install of C:S game and with only two mods enabled (TMPE and new version ModTools to see logs in game) and with save game which was built only with vanilla stuff.

It is actually quite simple to reproduce - errors start to show up when TMPE Parking AI is enabled and city has some walking tours and sightseeing bus tours which are used.

Errors are usually these two: _Citizen not found! at System.Environment.get_StackTrace() at Building.RemoveTargetCitizen(UInt16 instanceID, CitizenInstance ByRef data) at TouristAI.SetTarget(UInt16 instanceID, CitizenInstance ByRef data, UInt16 targetIndex, Boolean targetIsNode) at CitizenAI.SetTarget(UInt16 instanceID, CitizenInstance ByRef data, UInt16 targetBuilding) at HumanAI.ArriveAtDestinationPatch1(System.Object , UInt16 , CitizenInstance ByRef , Boolean ) at TrafficManager.Custom.AI.CustomHumanAI.CustomSimulationStep(UInt16 instanceId, CitizenInstance ByRef instanceData, Vector3 physicsLodRefPos) at CitizenManager.SimulationStepImpl(Int32 subStep) at SimulationManagerBase 2.SimulationStep(Int32 subStep) at CitizenManager.ISimulationManager.SimulationStep(Int32 subStep) at SimulationManager.SimulationStep() at SimulationManager.SimulationThread() [Core]

or

_Citizen not found! at System.Environment.getStackTrace() at NetNode.RemoveTargetCitizen(UInt16 instanceID, CitizenInstance ByRef data) at TouristAI.SetTarget(UInt16 instanceID, CitizenInstance ByRef data, UInt16 targetIndex, Boolean targetIsNode) at CitizenAI.SetTarget(UInt16 instanceID, CitizenInstance ByRef data, UInt16 targetBuilding) at HumanAI.StartMoving(UInt32 citizenID, Citizen ByRef data, UInt16 sourceBuilding, UInt16 targetBuilding) at HumanAI.StartMoving(UInt32 citizenID, Citizen ByRef data, UInt16 sourceBuilding, TransferOffer offer) at TouristAI.StartTransfer(UInt32 citizenID, Citizen ByRef data, TransferReason material, TransferOffer offer) at TransferManager.StartTransfer(TransferReason material, TransferOffer offerOut, TransferOffer offerIn, Int32 delta) at TransferManager.MatchOffers(TransferReason material) at TransferManager.SimulationStepImpl(Int32 subStep) at SimulationManagerBase 2.SimulationStep(Int32 subStep) at TransferManager.ISimulationManager.SimulationStep(Int32 subStep) at SimulationManager.SimulationStep() at SimulationManager.SimulationThread() [Core]

Fyi: It seems that if one wants to get rid of these error, it has to stop using tourist tours or parking AI. It also seems that this error stops occur when parking AI is disabled and game restarted.

New output.log: https://drive.google.com/file/d/1kEsRlDOn6Ki2G9Hw_ICRu-JlrBM8UOF0/view?usp=sharing new tmpe.log: https://drive.google.com/file/d/1icQfMWb9bwbzxVHqQphGOdCKSYCbTWM0/view?usp=sharing new savegame: https://steamcommunity.com/sharedfiles/filedetails/?id=2442664756

krzychu124 commented 3 years ago

@meda22 I think that link to the savegame is incorrect 🤔

meda22 commented 3 years ago

@krzychu124 ah sorry, that was wrong copy-paste :)

here is the correct link: https://steamcommunity.com/sharedfiles/filedetails/?id=2442664756 (I updated previous comment too)

meda22 commented 3 years ago

@krzychu124 I am also wondering - is it safe to continue to play save with same configuration (using tours and TMPE parking ai)? And just ignoring this errors? I am bit worried since it is from a simulationThread... so it wouldn't spoil the save.

krzychu124 commented 3 years ago

It's hard to say why game cannot find citizens but from I found it might be caused by missing assets - buildings (cim set target or was there - inside), you saved game, but then unsubscribed asset. If that's the case, it should be harmless. I'll continue investigation

meda22 commented 3 years ago

@krzychu124 Thanks for your answer...

I think it is not cause by missing asset, unfortunately... I have created new test save: https://steamcommunity.com/sharedfiles/filedetails/?id=2454123439

This city is saved with Advanced Parking AI off, so to simulate issue, you will have to enable it again. Only vanilla assets has been used in this city (it was newly created). Only following mods where enabled in addition to TMPE: ModTools Instant Return to Desktop Loading Screen Harmony and vanilla mods: unlimited money, unlimited soil, unlimited resources and unlock all milestones.

But yet again, when Parking AI enabled, errors starts to occur. I tried to investigate bit on my own - majority of that errors are thrown from Building.RemoveTargetCitizen(UInt16 instanceID, CitizenInstance ByRef data) so I debugged on that ones (though it can happen it is thrown from NetNode too or method AddTargetCitizen). So when that error happen, it is always a strange instance of building - I mean, InstanceId can't be found in BuildningManager.m_buildings and buildingInfo always says "Empty Park 12x8" and all attributes seems empty. When I was trying follow some citizen on tour path, I could see that error happened quite randomly and then citizen was marked as "confused". Also - but that is maybe different issue - it seems that pathfinding of citizens on tour walk is strange sometimes too... It can happen that they just start floating between tours points "as crow flies" (but there is no error message in these cases).

well, I hope that any of this info can help :)

krzychu124 commented 3 years ago

Ok, I found something. The reason why you see Empty Park 12x8(means unused ID (valid building has at least Created flag in m_flags)) while checking m_targetBuilding ID is that ID isn't building ID but node ID. I don't know yet why game tries to use that node ID that way.

meda22 commented 3 years ago

@krzychu124 I saw the fix - thanks for that! :) If I want to test it - is it safe to use that version from pull request in my "normal game" or should I rather test it on some test game to prevent some save game damage?

krzychu124 commented 3 years ago

@meda22 Bug itself was harmless if you don't mind disappearing citizens/vehicles before they enter parked car.

You can use master build. I didn't change anything in the save/load procedure so it should be safe to use it (always advised to create new save file instead of overwriting the old one). The latest version fixed some issues with exporting/importing goods when building are placed outside 25 tile area.

I plan to release it for more tests before I'll update it to Stable