The GOID (GameObjectID) "Zero" Issue and some inexplicable, bug looking mistakes

ek.skirl

Active member
Sounds somewhat mystic? Not at all. (;-) And at the end of that all I learned, that to avoid trouble with this "Zero"-GOID issue, it is necessary to use for the initial tasks a message handler for the "World", "ModuleInit'' message and NOT the Init, SetProperties and GetProperties methods. And additionally it may be a good idea to first add for every kind of object one will use in the route layer an unscripted (!) object (or with harmless Init, SetProperties and GetProperties methods) to exhaust this "Zero"-GOID's.

In some posts I searched for some backgrounds with the Init, SetProperties and GetProperties methods in conjunction with a scriptlibrary. To test that, I added to each of the methods a InterfaceLog method to see if the methods were executed. I logged the position and the GOID of the "me"-object.

The first sudden and unwanted result: In a empty, new created route/session pair with no one object, the preview of my asset logs the Init and the SetProperties log with the GOID "0,3,0,0," (here is 3 for scenery objects I think, 4 was used for the script library asset/object).
And if in this method some things like counting an object group or one time activating a dependent object or so, this isn't a good idea, because the result may be unwanted. Please remember this. I'll come back to this later.

Somewhere in the fields we may read that the GOID is unique over save/load cycles of the route/session. And for this the next sudden result appeared: Adding the object instance to the route layer shows me the same GOID for the object in the route layer ("0,3,0,0,") and the logs too.

Adding a second instance brings the next sudden thing: It gets the GOID "0,3,2,0,". Ok, another GOID as expected, but why not one? Trainz has its reasons, and of capital importance is the different GOID. And to tell it here early: The route-layer group uses even running numbers and the session layer group the odd ones.

But resuming my path I prepared the next two sudden result:
First I deleted the object with the "Zero"-GOID and it logged the GetProperties method. Don't know the reason, but Trainz should know. In order to avoid the question: At the end I post the script I used for my scenery object; it has additionally two attachment points to show the GOID at the object too.
Second, I switched to driver with ctrl-F2. And the just deleted object logs as a ghost. And the "Zero"-GOID-Ghost stays alive after storing the route/session. However when I start the session or the route in driver (directly or by switching), the ghost stays alive and logs his logs and hence executes the methods. Advantageous is the fact that the ghost will use the current script of the asset.

Thinking back, I remember that there were some issues with ghost vehicles in the past. I myself had the case where the steam of the loco retained visible, but the loco itself did not after derailing and disappearing. And one case was with the diesel steam after deleting the running loco while switching to surveyor. I don't remember what I did to solve this and I was not able to repeat this issue. So in my eyes it may be such a case with "Zero"-GOID?

To solve this issue by N3V it seems to me to be necessary to start the GOID running numbers in the router-layer with two and not with zero and save the "Zero"-GOID for the previews.
And until then it would be nice to have a set of harmless assets, one for every GOID-Group, minimum for Route/Session creators, associated with some more knowledge about the count of GOID-Groups Trainz uses.

The following script should run with any kind of asset. In some cases if the method still exists, it is necessary to add the needed parts of the script to the existing for test purposes.

Code:
include "MapObject.gs"
//---------------------------------------------------------------------------
// Object V1 Dummy <kuid2:215489:999990:1>
//---------------------------------------------------------------------------
class zerogoid isclass MapObject
{
  //-------------------------------------------------------------------------
  // Global variable for objects soup
  //-------------------------------------------------------------------------
  GameObjectID goid = me.GetGameObjectID();
  int value    = 100;
  string stext = "souptext";
  //-------------------------------------------------------------------------
  // Mandatory init method
  //-------------------------------------------------------------------------
  public void Init(Asset asset)
  {
    inherited(asset);
    //-----------------------------------------------------------------------
    // Set asset special initial values and methods
    //-----------------------------------------------------------------------
    AddHandler(me, "World", "ModuleInit", "ModuleInitHandler");
    //-----------------------------------------------------------------------
    // Show the goid on both sides of me
    //-----------------------------------------------------------------------
    SetFXNameText("GOIDV","[D]["+goid.SerialiseToString()+"]");
    SetFXNameText("GOIDH","[D]["+goid.SerialiseToString()+"]");
    //-----------------------------------------------------------------------
    // Log the init method is finished
    //-----------------------------------------------------------------------
    Interface.Log(Interface.GetTimeStamp()+" INIT FINISHED"
                + " GOID [" + goid.SerialiseToString() + "]");
    //-----------------------------------------------------------------------
  }
  //-------------------------------------------------------------------------
  void ModuleInitHandler(Message msg)
  {
    //---------------------------------------------------------------------
    // Log the handler method was called
    //---------------------------------------------------------------------
    int curmod       = World.GetCurrentModule();
    string timestamp = Interface.GetTimeStamp();
    string modul     = "NONE";
    if (curmod == World.DRIVER_MODULE)   modul="DRIVER";
    if (curmod == World.SURVEYOR_MODULE) modul="SURVEYOR";
    Interface.Log(timestamp + " WORLD MODULE INIT [" + modul + "]"
                + " GOID [" + goid.SerialiseToString() + "]");
    //---------------------------------------------------------------------
  }
  //-------------------------------------------------------------------------
  public void SetProperties(Soup soup)   // Callback method after Init method
  {
    inherited(soup);
    //-----------------------------------------------------------------------
    // Load values from soup
    //-----------------------------------------------------------------------
    value = soup.GetNamedTagAsInt("value",200);
    stext = soup.GetNamedTag("text");
    if (stext=="") stext="starttext";
    //-----------------------------------------------------------------------
    // Log the setproperties method is finished
    //-----------------------------------------------------------------------
    Interface.Log(Interface.GetTimeStamp()+" SETPROPS FINISHED"
                + " GOID [" + goid.SerialiseToString() + "]");
    //-----------------------------------------------------------------------
  }
  //-------------------------------------------------------------------------
  public Soup GetProperties(void)   // Callback method before closing session
  {
    Soup soup = inherited();
    //-----------------------------------------------------------------------
    // Store values to soup
    //-----------------------------------------------------------------------
    soup.SetNamedTag("value",value);
    soup.SetNamedTag("text",stext);
    //-----------------------------------------------------------------------
    // Log the getproperties method is finished
    //-----------------------------------------------------------------------
    Interface.Log(Interface.GetTimeStamp()+" GETPROPS FINISHED"
                + " GOID [" + goid.SerialiseToString() + "]");
    //-----------------------------------------------------------------------
    return soup;
  }
};

If someone is interested to get my test asset, please PM me an I will give you a temporary link to the zip file containing the cdp and original folder for private use.

A screenshot with the log from starting into driver and and a scene picture you will find here: screenshot

Picture-for-Blogpost-%22The-GOID-%28GameObjectID%29-%22Zero%22-Issue-and-some-inexplicable%2C-bug-looking-mistakes%22.jpg
 
Last edited:
Interesting. I remember participating in one or more of the threads where you were dealing with issues that clearly relate to this.

I`m not quite sure that I understand the issues here, though. For starters, am I to understand that your test-object script continued to execute even after you had deleted the object, saved the route, and reloaded the route? That should be impossible. I seem to be having rather the opposite problem: my assets die after unpausing, and show no further signs of activity. Do you think that your problem and mine might stem from the same set of changes that N3V made shortly before releasing build 123801?
 
continued to execute even after you had deleted the object, saved the route, and reloaded the route?
But it does.
my assets die after unpausing, and show no further signs of activity
No, I don't. This happens to mesome weeks ago too. But the reason was an empty object some were in my fields. A hint was a small logged error that I over readed some days long. And I inserted so many Interface.Logs to find the real position the error accurs.
 
But it does.
I believe you. Just because it should be impossible doesn`t mean that it is impossible.
No, I don't.
Don`t what, believe that there is the possibility of a connection?
This happens to mesome weeks ago too.
I recall discussing some of that.
But the reason was an empty object some were in my fields.
I don`t understand.
A hint was a small logged error that I over readed some days long.
Missing a critical log message can easily happen when you are flooding the output with messages.
And I inserted so many Interface.Logs to find the real position the error accurs.
Exactly what I was doing when actively editing my project. I think that I`m almost ready to get back to active development, but each time I think that, something else crops up and gets in the way.

As I`m sure you have already noticed, I sent a request for your test object. In addition to demonstrating your issue to me, I would like to use it as an alternate debugging output channel for my project. I will not release it without your permission, and if I do release it (with permission), it will be with my own script, not yours.
 
that there is the possibility of a connection?
yes
reason was an empty object
Oh, my sekretary needs some hearing issue (,-) should be not empty but faulty.
are flooding the output with messages.
Of course :cool:
I would like to use it as an alternate debugging output channel for my project. I will not release it without your permission, and if I do release it (with permission), it will be with my own script, not yours.
No special license to it, but telling the source of the original. Use as is or change to your needs. As anker points to the GOID-Text you may use of course any other att point too, for instanc to vehicles the a.limxxx.
 
Of course: credit where credit is due. If you don`t mind, I`ll examine your script for how to attach text to the display points, as I haven`t a clue yet how to do so. I could really use a nice large sign, like, say, a billboard, with an editable-text attachment point. It not only could be used for scenery that looks like it belongs in the route, but could also be used for a debugging output point. Heh, an entire line of such objects of various sorts could come in handy, methinks. Much appreciated. Thank you.
 
Oh. You are referring to setting the color of the displayed text on objects with "editable text"? Hmm. Yes, there should be such an option. It doesn`t seem to be working for you? Yes, there seems to be lots of broken things in recent releases of Trainz. Unfortunately, I lack expertise in that part of Trainzing. :(
 
If the colors are settable in GameScript, they can be made settable in the Properties dialog. Just because they are settable in config.txt doesn`t mean that they are settable by scripts, though.

As for backgrounds, you could always set an appropriate background for the text on the 3d object`s texture image. With scriptable texture changes, even that would be scriptable, within the limits of the available textures.

I have seen that tutorial, but I`m into scripting, not modeling, so I did not study it closely.

You aren`t thinking of creating scriptable billboards for me, are you? Yes, I commented that they would be useful, and they certainly would be, but it was intended more as an idle wish than a serious request.
 
I have seen that tutorial, but I`m into scripting,
The most parts discus scripting.
If the colors are settable in GameScript, they can be made settable in the Properties dialog.
That is obvious.
Just because they are settable in config.txt doesn`t mean that they are settable by scripts, though.
And that too.
As for backgrounds, you could always set an appropriate background for the text on the 3d object`s texture image.
Good idea, but not for me, because I'm not that blender-texturing expert.
You aren`t thinking of creating scriptable billboards for me, are you?
No, never. I used the name effect only for the "Zero"-GOID-problem and the Init, SetProperties, GetProperties, ModuleInit message problem.
 
Yes, that section of the tutorial has a fair amount of scripting, but the tutorial as a whole is mostly about constructing the engine shed.

Agreed that they are both obvious, but it is far from obvious to me who else might think so, especially as I have a habit of expecting people to see what I find obvious only to be disappointed. I have Asperger`s Syndrome, and that allows me to see "obvious" things that other people often simply cannot see. As if that isn`t enough, communicating this way tends to make judgement of other people`s skills and knowledge even more difficult to judge. Besides that, not everyone reading this in the future will have the background to see the obviousness of the statements.

Ok. Fair enough. Neither am I.

Ok. Fair enough, but what you had to say since my mention of them could easily have been in support of that, and I just wanted to be sure, one way or the other. I now realize that it was in support of me using your box that you made those comments. I just couldn`t tell at the time. (y)

I`m sorry if this seems too terse; I have a headache this morning and somewhere else to be soon.
 
Back
Top