Multiplayer Shop Menu: Is he idle or just shopping?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Multiplayer Shop Menu: Is he idle or just shopping?

Post by MCP »

So this is a problem common to many games:
it can take a couple of minutes to finish shopping at the shop menu.

However in the mean time the other players have no idea what is happening.

What I want to happen is,
when a person moves onto a shop it will display 'Shopping...' or something as a label on the map, which is simple. The problem is, this will not update until the person leaves the shop. I need it to update for everyone else when the person moves onto the shop.

Any ideas?
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by Sapient »

I don't think there's a way to do that currently. Potentially, you could break down the shop into seperate menu items instead of cramming it all into a really long [message] loop
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by MCP »

Thanks Sapient I'll give it a try if Zeus' idea does not work.

At least they can appreciate 'Welcome to the shop, press enter or double click here to continue' and it will open up a new shop possibly allowing this to work.


Zeus had noticed, when they go onto the shop in DotG any gold they are carrying is reduced to zero as it is stored in a 'bank' variable, this is visible to everyone. So I think I might be able to update a label there and everyone can see it, even though their character's position hasn't updated yet.

So either way I think this will work out as soon as I can give it a try.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by Sapient »

No, I mean multiple [set_menu_item]s.

As you may know, you can change the menu items by re-using the same menu item id number.

As an example, instead of a menu item that says "Shop" you would have three menu items "enter Armor Shop", "enter Bank" and "enter Magic Shop."

Then if you choose Magic Shop, your menu items would change to "buy Crystal Ball (300g)", "Oblivion Sceptre (20g)", and "Leave Magic Shop"

every time a menu item is finished processing, it transmits the synchronization information (and allows you to pause and communicate)
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by MCP »

First off thanks for trying to help, no matter the out come.

Well what Zeus said is incorrect, at least so far as my testing.
If they enter the shop, it doesn't immediately synchronize showing their gold dropping to zero, or else the labels trick would have worked in the same place.

The way DotG Shop works is:
The leader just stands there until suddenly all at once, anything they did in the shop is gone through one at a time, in order, at 'computer speed'. So it can appear their HP suddenly grows, with a quick animation of counting up to go with it. But when a person buys a damage in the shop, it doesn't synchronize anything that appears on the screen for other people.

Now the Shop I refer to doesn't seem to be the same thing as your menu item.

In fact I do not yet even understand Baufo's code for the shop at all...
You'd have to d/l it from the add-ons and look for yourself at #define SHOP
It's not a right click menu item like perhaps you are thinking of(?)

So it might be that I need to completely redo the shop functions to make use of menu items?
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by MCP »

I'm not going to let this dream die.

So when someone moves onto a specific location it pops this shop up.

What exactly synchronizes the players? Is it the shop menu closing? I think so. In this case, just pop a pre-shop up, hit ok, then the real shop can pop up after. Perhaps this will work, perhaps not.

I definitely tried a few things in WML, but none of them would synchronize all the players.
Skizzaltix
Posts: 1114
Joined: December 9th, 2005, 2:38 am

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by Skizzaltix »

By "menu item", I believe Sapient means "those little highlighted bits of text in in-game messages that you can click on and stuff happens"--Though, I'm not familiar with the map in question (It's another DotA clone, right?), so I could be wrong... But your description of the shop outcome does rather make it sound like the menu loop he is referring to.

Here's a question on a side note... I seem to recall reading/hearing/imagining that what the game does during online play is wait for the current player to end his/her turn, and then replay it back to the other players? If this is so, which I find somewhat doubtful, then your task here could be rather difficult... :hmm:
-stf-
Posts: 76
Joined: December 19th, 2007, 10:27 pm
Location: Prague, Czech Republic
Contact:

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by -stf- »

I'll try implement that in SXCollection, if it will work, you can use it in your addons as well. It should work, I think, just another way.
User avatar
Viliam
Translator
Posts: 1341
Joined: January 30th, 2004, 11:07 am
Location: Bratislava, Slovakia
Contact:

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by Viliam »

Sapient wrote:I don't think there's a way to do that currently. Potentially, you could break down the shop into seperate menu items instead of cramming it all into a really long [message] loop
How about this: When you enter the shop...
1) The label on hex is changed to "Shop (customer inside)"
2) The long [message] loops starts
3) The label on hex is changed to "Shop" again
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by MCP »

I'm pretty sure I tried the label and it did not 'work', that is it won't show up for anyone besides the player whose turn it is, until that player leaves the shop.

So by 'label' I mean,
I had a separate event right before the shop that would pop a label up.
-stf-
Posts: 76
Joined: December 19th, 2007, 10:27 pm
Location: Prague, Czech Republic
Contact:

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by -stf- »

Seems even separate events on one hex are running as one big event and update for other sides is sent after all events are done (why separate events are not send also separately?). Also [redraw] for all sides doesn't work. Weird. Is it a bug in [redraw]?
If there would be event movefrom, it should help, because it would be started as really separate event, fired just before move animation, but that event is not still implemented (why? It should help in many cases - even in normal situations - if unit has i.e. 12 movements, that is pretty big number of hexes to check, much more problem if there are many units and scenario designer doesn't know unit's name, description or anything else before game starts). Or at least second_filter for moveto would be that hex (even if it can't help in this particular situation).
If anybody will not find usable method, i see only one way than can work but also can be that it will not work... Still, it's a little chance yet remaining.

In association with this I have an idea - new variable for [redraw] such as this:
[redraw]
synchronize=yes
[/redraw]
(would send redraw command to all players in multiplayer except in dialogs shown with [message] tag for current player within event but anywhere else in event it can work with no OOSes)
I don't think it is too hard to include this already in 1.4.7 (as unknown commands or variables are ignored it can be only difference in time, when it will send data to other players - 1.4.7 immediately, older 1.4.x sae way as before).
For people knowing PHP, it is meant as equivalent for flush() command in PHP.
CIB
Code Contributor
Posts: 625
Joined: November 24th, 2006, 11:26 pm

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by CIB »

Well, I guess you do not really understand how Wesnoth synchronizes. I do not fully understand it so far, either, but it seems to work roughly like this:

- the player makes a move
- the movement is written to the replay data
- events are fired, WML is called, all player input is written to the replay data
- the replay data is sent to other players, who then execute all the WML again and take the input in the replay data into account

This means Synchronization is only determined by the player's non-WML moves, such as moving a unit or attacking. All WML triggered within these moves will be sent to other players as soon as the move is done only. This means that it is impossible to update more than once within one move.
Skizzaltix
Posts: 1114
Joined: December 9th, 2005, 2:38 am

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by Skizzaltix »

:O
I guess I was right about the replay...

Actually, is there a way to trigger an in-game chat via WML? Couldn't you send an allies-only chat when the player enters the shop that says "Shopping!" and then another when they leave that says "Done now."? :hmm:
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by Sapient »

Did nobody read my post yet?
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-stf-
Posts: 76
Joined: December 19th, 2007, 10:27 pm
Location: Prague, Czech Republic
Contact:

Re: Multiplayer Shop Menu: Is he idle or just shopping?

Post by -stf- »

CIB wrote:- the player makes a move
- the movement is written to the replay data
- events are fired, WML is called, all player input is written to the replay data
- the replay data is sent to other players, who then execute all the WML again and take the input in the replay data into account

This means Synchronization is only determined by the player's non-WML moves
If this is so, then I don't see any problem in dividing replay data and/or player input into 2 or more parts with special keyword. If I can find where it is in source (it's too complex for me at this time - not enough time to study this) I think it can be changed with no problem. It's the same as I can send all this text as 1 message or I can divide it into 3 messages, all containing only i.e. 4 lines of text. Result is also the same.

Again PHP: you can send whole table as 1 piece of data after it's generated, or you can send every line immediately after its content is retrieved from database. In first case you can wait some time and think your browser lost connection to server (browser will assume that if timeout is set too low). In second case you see every line just after it's received and browser never assume it's broken connection. This works in all programming languages I know (PHP, BASIC, PASCAL, C++, BASH). In all of them you can first calculate all variables and then generate output or you can generate output immediately after some of these are calculated and then continue same way.

Don't say it's determined only by move - while I use potion from context menu, it's shown to other players immediately after I do that (tested on local server with 2 instances of Wesnoth).
Post Reply