Giter Site home page Giter Site logo

quistar-lab / treeanarchy Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 1.42 MB

Tree Anarchy. This is a rewrite of the original Unlimited Trees mod in order for tree snapping to function

License: MIT License

C# 100.00%
cities skylines unlimited trees tree snapping

treeanarchy's People

Contributors

quistar-lab avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

algernon-a

treeanarchy's Issues

Enable/Disable tree ruining?

Tree ruining calls two mathf method... If ruining is removed.. should improve fps..
Though I'm not sure if to keep this as an option or to permanently remove it.

Tree anarchy options a bit confusing

These options specifically:

image

The main Tree Anarchy option is about being able to place trees anywhere, then immediately below there's options for hiding/deleting trees... which is the opposite of the purpose of tree anarchy?

Would these options be better expressed as a drop-down, something like:

Trees under buildings/networks should: [drop down menu]

And the menu items would be:

  • remain visible
  • be hidden
  • get bulldozed

I'm assuming here that user want's consistent effect if they are using anarchy - eg. they want same thing for all trees.

Exception thrown on startup

Note: This only started happening after update on 5th Dec 2021.

When the mod is loaded it's throwning an exception which is breifly visible on the main menu screen but then disappears as soon as city loading screen appears.

ArgumentException: Label not marked
  at System.Reflection.Emit.ILGenerator.label_fixup () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.DynamicMethod.CreateDynMethod () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at MonoMod.RuntimeDetour.Platforms.DetourRuntimeMonoPlatform.GetMethodHandle (System.Reflection.MethodBase method) [0x00000] in <filename unknown>:0 
  at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform.Pin (System.Reflection.MethodBase method) [0x00000] in <filename unknown>:0 
  at MonoMod.RuntimeDetour.DetourHelper.Pin[MethodInfo] (System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 
  at HarmonyLib.MethodPatcher.CreateReplacement (System.Collections.Generic.Dictionary`2& finalInstructions) [0x00000] in <filename unknown>:0 
  at HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) [0x00000] in <filename unknown>:0 
  at HarmonyLib.PatchProcessor.Patch () [0x00000] in <filename unknown>:0 
  at HarmonyLib.Harmony.Patch (System.Reflection.MethodBase original, HarmonyLib.HarmonyMethod prefix, HarmonyLib.HarmonyMethod postfix, HarmonyLib.HarmonyMethod transpiler, HarmonyLib.HarmonyMethod finalizer) [0x00000] in <filename unknown>:0 
  at TreeAnarchy.TAPatcher.EnableTreeInstancePatch (HarmonyLib.Harmony harmony) [0x00000] in <filename unknown>:0 
  at TreeAnarchy.TAPatcher.EnableCore () [0x00000] in <filename unknown>:0 
  at CitiesHarmony.API.HarmonyHelper.DoOnHarmonyReady (System.Action action) [0x00000] in <filename unknown>:0 
  at TreeAnarchy.TAMod.OnEnabled () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at ColossalFramework.Plugins.PluginManager.AddPlugins (System.Collections.Generic.Dictionary`2 plugins) [0x00000] in <filename unknown>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
ColossalFramework.Plugins.PluginManager:AddPlugins(Dictionary`2)
ColossalFramework.Plugins.PluginManager:LoadPlugins()
Starter:Awake()

Will try and attach log file, but it's pretty huge...

Error starting Cities Skylines

Ever since, i think v1.2.4 I receive this message after updating TreeAnarchy, whenever I start up Cities

A Mod caused an error [System.Exception]

Details:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
at TreeAnarchy.TALocale.GetLocale (System.String name) [0x00000] in :0
at TreeAnarchy.TAOptionPanel.ShowTreeAnarchyOptions (ColossalFramework.UI.UIPanel panel) [0x00000] in :0
at TreeAnarchy.TAOptionPanel.SetupPanel (ColossalFramework.UI.UIPanel root) [0x00000] in :0
at TreeAnarchy.TAMod.OnSettingsUI (UIHelperBase helper) [0x00000] in :0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception

Lock Forestry

I think your Option should have the either same setting as the 'Lock Forestry Resource' mod or should inform that there is another Mod active doing the same and pathing that one out...

ATM both conflict each other... 'Lock Forestry Resource' mod is on locked status and TreeAnarchy not... but 'Lock Forestry Resource' mod is used for locking

btw... it would be nice to have a shortcut for this to activate/deactivate and an visible indicator ingame (maybe recolor the Landscaping UI icon or Forest Brush UI button if that one is installed

Airports update loading issue

I get this error message when loading after Airports update.

A Mod caused an error [System.Exception]

Details:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> HarmonyLib.HarmonyException: IL Compile Error ---> System.FormatException: Method virtual System.Void TreeTool::RenderOverlay(CameraInfo cameraInfo) cannot be patched. Reason: Invalid IL code in (wrapper dynamic-method) TreeTool:TreeTool.RenderOverlay_Patch0 (TreeTool,RenderManager/CameraInfo): IL_0140: call 0x00000045

at HarmonyLib.Memory.DetourMethodAndPersist (System.Reflection.MethodBase original, System.Reflection.MethodBase replacement) [0x00000] in :0
at HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) [0x00000] in :0
--- End of inner exception stack trace ---
at HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) [0x00000] in :0
at HarmonyLib.PatchProcessor.Patch () [0x00000] in :0
at HarmonyLib.Harmony.Patch (System.Reflection.MethodBase original, HarmonyLib.HarmonyMethod prefix, HarmonyLib.HarmonyMethod postfix, HarmonyLib.HarmonyMethod transpiler, HarmonyLib.HarmonyMethod finalizer) [0x00000] in :0
at TreeAnarchy.TAPatcher.EnableTreeVariationPatches (HarmonyLib.Harmony harmony) [0x00000] in :0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0
at ColossalFramework.Plugins.PluginManager.AddPlugins (System.Collections.Generic.Dictionary`2 plugins) [0x00000] in :0

Fire Safety infoview not showing 'watched trees'

In Fire Safety info view, when zoomed out, the trees no longer highlight with blue-red colors showing whether trees are being 'watched' by fire towers, etc.:

image

If I zoom in, they start becoming colorised:

image

In vanilla it would show fire coverage of everything in the camera view regardless of distance.

Trees reappearing on roads/etc when reloading game

I will turn off anarchy to place roads and other things on the map (see pic)
Screen Shot 2022-07-03 at 9 09 02 AM
and trees will not collide with whatever I am placing, which is my expected behavior.

When reloading my game however any trees that were colliding with these placed objects are now visible. I might just be misunderstanding how to use this mod, but just in case it is a bug want to report it here :)

Game Stuck / Tree Rotation

After a while - and i can't say if there is any specific action causing it - the game stucks... to explain:

The UI can be clicked but nothing can be selected on the map nor can i unpause the game. I can open any kind of menu and activate any tool... but they are not working... Every time i had this (third time now) i was using Forest Brush and the only tree relevant mod i've changed is yours.

Only option i have after such a stuck is to close the game to desktop using the menu

Please find attached my logs
output_log.txt
TMPE.log

Second Point i had: I excluded Tree Movement Control, as it's functions seems to be included in Tree Anarchy... but for me the Trees do not rotate then...

Exceptions writing to log file

Users are reporting exceptions when writing to log file (primarily contested access - antivirus perhaps? - but also other reasons, the usual slings-and-arrows of IO access). Not a problem in itself - quite expected for file IO - but the mod currently isn't catching any logfile writing exceptions and thus crashes out (usually resulting in a simulation error and inability to play the game).

Performance enhancement

Cities Skylines uses .Net 3.5 Framework which is quite old and the CLR used does not support the CPU enhancements we have today, especially when it comes to SSE2 or AVX2 special instructions.

Drawing trees requires a lot of math, and with the original limit of 262144 trees, this wasn't too much of a problem, but with Unlimited Trees mods, we need to account for the possibly increased trees of up to millions.

Running a loop through 262144 is fast and can be completed within 50ms, but if its looped through 1 million trees, then that 50ms will become 200ms and maybe more due to branching and threading synchronizations.

My proposed solution is to go around this and add a wrapper to my mod to create access to SSE2 and AVX2. This doesn't come with a caveat and that is, there is a performance hit when switching between managed and unmanaged codes. BUT, I'm certain that the switch will be negligible compared to the current IL codes being generated by the old CLR2.0 (.Net3.5 Framework).

An example would be Unity functions Mathf.Min/Max. These functions, when compiled into IL results in around 10 instructions with branches. But if using AVX or SSE special instructions, the same results can be achieved using just 3 assembly instructions.
That would be a ~5x improvement over the original methods. And worth considering.

Burning trees turn invisible

Trees that are on fire somtimes turn invisible...

Trees over a road always seem to turn invisible (these were manually placed over grass verge with tree anarchy enabled):

image

image

This tree was manually placed over a building asset:

image

The asset did not contain a tree (it was just seating):

image

However, the tree trunk remains visible for burning trees that are over normal terrain:

image

So the issue seems to be that when burning tree is on a building/network (where normally the game would hide it, but I've used anarchy to keep them visible) the tree trunk is turning invisible?

That being said, here's another example of tree manually placed over a building (blue border shows building footprint) which hasn't turned invisible...

image

Although that specific building doesn't paint pavement under it, hence normal terrian being visible within its footprint.

Log files:
00PropAnarchyDebug.log
00TreeAnarchyDebug.log
oEManagerDebug.log
output_log.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.