News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

call_[something]_tool and the "extra" character

Started by jamespetts, March 16, 2010, 11:48:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

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).

sscanf( p, "%c,%hi,%hi,%hi,%hi,%c", &tool, &pos.x, &pos.y, &z, &convoi_id , &exptool);

The trunk code should ignore the exptool.
Parsley, sage, rosemary, and maggikraut.

jamespetts

Dwachs,

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

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

Parsley, sage, rosemary, and maggikraut.

jamespetts

The second argument in the call_convoi_tool method.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

Quote from: jamespetts on March 16, 2010, 12:36:46 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.
Parsley, sage, rosemary, and maggikraut.

jamespetts

Quote from: Dwachs on March 16, 2010, 03:12:56 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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

jamespetts

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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

jamespetts

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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

Parsley, sage, rosemary, and maggikraut.

jamespetts

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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

cbuffer_t is defined in utils/cbuffer* ...

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