The International Simutrans Forum

 

Author Topic: call_[something]_tool and the "extra" character  (Read 3750 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20918
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
call_[something]_tool and the "extra" character
« on: March 16, 2010, 11:48:06 AM »
A quick question for the main developers: how does one make use of the supplementary ("extra") character in the call_[something]_tool methods in simwerkz.cc? There is a short routine for extracting the main character to a char tool field in call_convoi_tool and call_depot_tool, but this is not replicated for the "extra" character. Is there some code somewhere that I can copy? Thank you.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: call_[something]_tool and the "extra" character
« Reply #1 on: March 16, 2010, 12:13:42 PM »
maybe implement your 'experimental' stuff in a case 'X': of the main switch there. Then extract your secondary character and switch again (so two nested switch's).
Code: [Select]
sscanf( p, "%c,%hi,%hi,%hi,%hi,%c", &tool, &pos.x, &pos.y, &z, &convoi_id , &exptool);
The trunk code should ignore the exptool.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20918
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: call_[something]_tool and the "extra" character
« Reply #2 on: March 16, 2010, 12:36:46 PM »
Dwachs,

thank you for your reply. Would this be instead of or as well as the current "extra" character?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: call_[something]_tool and the "extra" character
« Reply #3 on: March 16, 2010, 12:46:36 PM »
what extra character do you refer to?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20918
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: call_[something]_tool and the "extra" character
« Reply #4 on: March 16, 2010, 02:27:20 PM »
The second argument in the call_convoi_tool method.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: call_[something]_tool and the "extra" character
« Reply #5 on: March 16, 2010, 03:12:56 PM »
thank you for your reply. Would this be instead of or as well as the current "extra" character?
.. then I would say: in addition to this extra parameter.

And please say, which letter you will use for the experimental's features, such that this letters can be commented as 'reserved' in standard trunk.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20918
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: call_[something]_tool and the "extra" character
« Reply #6 on: March 16, 2010, 03:30:03 PM »
.. then I would say: in addition to this extra parameter.

And please say, which letter you will use for the experimental's features, such that this letters can be commented as 'reserved' in standard trunk.

I'm slightly confused - do you want me to use a reserved list of letters for Experimental, or use a special extra parameter as discussed above?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: call_[something]_tool and the "extra" character
« Reply #7 on: March 16, 2010, 03:33:59 PM »
List of reserved letters for new features.

Or do you speak about just modifying the standard behavior of the tools to fit your needs? Then an extra parameter would do this.

I think a simutrans-standard server should be able to ignore experimental commands actively: The server should notice when an experimental command arrives (hence the reserved letter .. a command with a reserved letter is from experimental and will be ignored).

Maybe this should be handled upon joining of clients: such that a standard server will reject experimental clients and viceversa.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20918
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: call_[something]_tool and the "extra" character
« Reply #8 on: March 16, 2010, 09:56:28 PM »
Given that Standard servers will never be compatible with Experimental clients, rejecting on joining seems much more sensible. But that brings me back to my original question, which wasn't about differentiating Experimental on a server at all - how do I make use of the existing feature to use a second character in those tools?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: call_[something]_tool and the "extra" character
« Reply #9 on: March 17, 2010, 06:09:02 AM »
It seems I misunderstood you. The extra parameter contains a schedule (convoi tool) or a window magic number (line tool).

See eg.  fpl->sscanf_schedule( p ); and the corresponding sprintf.

You can use the extra parameter as you like. It is only interpreted under certain circumstances, as you can see in simwerkz.cc.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20918
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: call_[something]_tool and the "extra" character
« Reply #10 on: March 17, 2010, 09:19:10 AM »
I have managed to get it working as an additional character, which is useful for re-using code where there are multiple related tools. One other question: do the letters have to be unique across all tools, or just unique for the particular type of tool?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: call_[something]_tool and the "extra" character
« Reply #11 on: March 17, 2010, 09:41:28 AM »
unique for the particular type of tool?
only this.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20918
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: call_[something]_tool and the "extra" character
« Reply #12 on: April 11, 2010, 02:02:00 PM »
Dwachs,

I have been looking at this to-day and I think that I see how it works. However, a further question: where is the cbuffer_t object containing the schedule transmitted accross the network?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10828
  • Languages: De,EN,JP
Re: call_[something]_tool and the "extra" character
« Reply #13 on: April 11, 2010, 07:14:46 PM »
cbuffer_t is defined in utils/cbuffer* ...

And it is transferred as a string, since its size is known.