Jump to content

11 posts in this topic Last Reply

Highlighted Posts

Hi guys can anyone help me with that issue i don't get it...

 

using ICities;
using ColossalFramework.Plugins;

namespace Whatever
{
    public class Whatever : IUserMod
    {
        public string Name => "Whatever";
        public string Description => "it does somethin";
    }
    public class Loader : LoadingExtensionBase
    {

        public override void OnLevelLoaded(LoadMode mode)
        {
            DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "hopla");
        }

    }
    public class BuildingListener : BuildingExtensionBase
    {
        public override void OnBuildingRelocated(ushort id)
        {
            base.OnBuildingRelocated(id);
            DebugOutputPanel.AddMessage(PluginManager.MessageType.Message,"relocated for id " + id.ToString()); // this is the line crashing the game note that without the " + id.ToString()" it works
        }

    }
}

Share this post


Link to post
Share on other sites
21 minutes ago, noobSkyliner said:

DebugOutputPanel.AddMessage(PluginManager.MessageType.Message,"relocated for id " + id.ToString()); // this is the line crashing the game note that without the " + id.ToString()" it works

I'm prolly way out of my element, but what happens if you use & id.ToString() instead of + id.ToString() ?

Edit: Also, does id.ToString need something in those parenthesis? Like id.ToString(id) ?

Edit Too: If that happens to be LUA the ... is used for string concatenation. *;)

Share this post


Link to post
Share on other sites
  • Original Poster
  • 2 hours ago, CorinaMarie said:

    I'm prolly way out of my element

    no disrespect but it seems so.

    well, like that, i can't think of any language using & for concatenation...

    php uses dot shell uses &&

    in c /c++ u use it to get the adress of a variable or to mutliply bits (ie bitwise AND operator)

    but in c# afaik it's only for bitwise AND ; and yes i'm sure string concatenation is done with + operator ;)

    also in the parenthesis if a non optional parameter was needed the compiler would not compile ;)

    I didn't check but i guess i can put an optional parameter to specify the basis (like decimal which is default, binary, hexa...)

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • 23 hours ago, Ronyx69 said:

    DebugOutputPanel.AddMessage instead of just using Debug.Log

    from my understanding Debug.Log is the generic function (ie unity native function)

    and DebugOutputPanel.AddMessage is the skyline api wrapper for debug.log (after testing it's more than that as debug.log doesn't output in the ingame panel shown by pressing F7)

    after testing with debug.log it doesn't crash anymore :) ty dude

    but the good thing about debugoutputpanel is i had debug result ingame by presssing F7 (which show/hide that famous debugoutputpanel) .

    I guess with debug.log it's a real debug output (ie in console) if so the main diff is i would have to attach my process to a debugger to get such console ?

    sorry i'm pretty new to unity i'm more familiar with godot (open source alternative)

    oh and finally why was i using debugoutputpanel ? cause it's what they do in the modding wiki and any hello world exemple i saw..

    Share this post


    Link to post
    Share on other sites
    1 hour ago, skylinoob said:

    from my understanding Debug.Log is the generic function (ie unity native function)

    and DebugOutputPanel.AddMessage is the skyline api wrapper for debug.log (after testing it's more than that as debug.log doesn't output in the ingame panel shown by pressing F7)

    after testing with debug.log it doesn't crash anymore :) ty dude

    but the good thing about debugoutputpanel is i had debug result ingame by presssing F7 (which show/hide that famous debugoutputpanel) .

    I guess with debug.log it's a real debug output (ie in console) if so the main diff is i would have to attach my process to a debugger to get such console ?

    sorry i'm pretty new to unity i'm more familiar with godot (open source alternative)

    oh and finally why was i using debugoutputpanel ? cause it's what they do in the modding wiki and any hello world exemple i saw..

    I'm not a programmer, I am just an amateur modder. But I've made a bunch of mods and I have no idea what you're talking about.

    F7 IS the console, and that's where Debug.Log shows up ingame - in the F7 console, I have no idea what this debug output panel is.

    Are you not using mod tools? That's my only guess.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • 1 hour ago, Ronyx69 said:

    Are you not using mod tools? That's my only guess.

    indeed i'm not .

    this code is just a first attempt so i used a minimal config (well i got visual studio but i even let cityskyline compile my source code by itself as i noticed a framework version difference betweeen my visual studio compiler and the game one. For exemple my visual studio (even though the project is configured for .Net3.5 supports expression like :

    public string Name => "Whatever";

    while the game compiler doesn't understand that notation and wants a

    public string Name {get {return "Whatever";} }

    I will try modtools ty

    So after trying with modtools it works as expected ty; but i would still want an explanation from anyone who has an idea about that issue.

    so the issue is simple to sum up :

    void whatever (ushort a){

    string s = "local var";

    DebugOutputPanel.addMessage (s);

    } IS WORKING (yes i tried taht too)

    void whatever (ushort a){

    DebugOutputPanel.addMessage ("LitteralString" + a.toString());

    } IS CRASHING !!

    void whatever (ushort a){

    Debug.Log ("LitteralString" + a.toString());

    } IS WORKING !!

    I'm kinda lost here.. someUnsignedShort.toString () should never crashes as the content of the memory pointed by someUnsignedShort can be interpreted as an unsigned short whatever is value is and an unsigned short can always be converted to a string (without unsafe operations (except the allocation of the returned string.. would that mean DebugOutputPanel.addMessage call is taking all available memory ? leaving nothing for that string allocation ?? sounds crazy... Not even taht is possible btw as this is a static call... i'm really lost ;( so sad))

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • 2 hours ago, Ronyx69 said:

    I have no idea what this debug output panel is

    u might have heard about it if u're using modtoools by mr bloodypenguin when u start the game press F7 scroll on top and see the blue text claiming that "you should no longer use DebugOutputPanel" ;)

    Share this post


    Link to post
    Share on other sites

    Without an exception message or output_log, it is hard to tell what the issue is.

    Are you using Visual Studio?

    Maybe a is null? You can try string interpolation, which is generally nicer than ToString(), although I think it will also call ToString() internally:

    DebugOutputPanel.addMessage($"LitteralString {a}"); 

    In general, the game's output panel is less reliable than the ModTools console, so I would always recommend you to use ModTools.

    Attaching a debugger is not easy and I never tried it. Here are some instructions:
    https://www.reddit.com/r/CitiesSkylinesModding/comments/7zaysk/debugging_as_attached_debugger_for_visual_studio/

     

     

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • after Trying with

    DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, $"relocated for id {id}");

    i get the same invalid adress error (like i'm trying to use some "non existing anymore " resource...

    output_log    https://pastebin.com/5s95iGQX
    error.log        https://pastebin.com/hXNVVCaq

    This still doesn't make sense to me as :

    the life cycle of var s in

    void whatever (ushort a){

    string s = "local var";

    DebugOutputPanel.addMessage (s);

    }

    is from void whatever  first line to void whatever last line

     

    the life cycle of $"relocated for id {id}" is from that call to the end of the call (ie end of DebugOutputPanel

     

    Also $"relocated for id {id}" should normally be calculated before the call to debugoutputpanel and should be free when this function return (returns void in DebugOutpuPanel.addMessage but still returns).

    I don't often code in c# (my last experience is pretty old) but i guess the var s in the first case is passed by value and not by ref; if so there is no real difference between

    DebugOutputPanel.addMessage (s);

    and

    DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, $"relocated for id {id}");

    in both case a memory space for the length of the string should be allocated before calling DebugOutputPanel.AddMessage (for s it will be just a memcopy while for $"relocated for id {id}" it will resolve the expression and then do the assigning) and the adress of this space must be given as argument to the call to DebugOutputPanel.AddMessage and that memory would be release when the DebugOutputPanel.AddMessage will return... So i'm still lost ;(

    Btw for my dev i now use modtools so my issue is solved in a way but i still would like to understand the error here. Ty for your time guys :)

     

     

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account

    Sign In  

    Already have an account? Sign in here.

    Sign In Now


    • Similar Content

      • By henko151
        Hello!
        I´m beginner, but I start build my new city which named "Henkovce". I started with Vanilla, but  gradually I add some mods. Today, my city has 25 000 citizens, 7 bus line and 2 tram line.
        And my first video is from my first tram line 1.
        Thanks for watching and please let me know about some tips and mods for my city.
         
      • By caprisio
        i downloaded the mod from ronyx69 and its not working every other shape is working i dont know what is wrong with the asphalt
         

      • By jasonsmithgoat
        https://steamcommunity.com/sharedfiles/filedetails/?id=1457517937
        Working on the prop version as well the new wrapped trains.
      • By Bad Peanut
        so I've been waiting for sub buildings to become native so I could finally finish off Flinders Street Station (from Melbourne) here's a quick WIP look - probably will release sometime soonish - maybe next week.

        Let me know what you guys think!



      • By R3V0
        Hello, 
    • Recently Browsing   0 members

      No registered users viewing this page.

    ×

    Thank You for the Continued Support!

    Simtropolis relies mainly on member donations to continue operating. Without your support, we just would not be able to be entering our 15th year online!  You've really help make this a great community.

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running, so that we can help keep bringing SimCity players together to share our creations.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Echange.
    Make a donation and get one or all three discs today!

    stexcollection-header.png

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections