wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > - Submit a resource -
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 12-08-2010, 08:04 PM   #16
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by Anitarf
Yes, initial value is a preference, my point was, if a user has that preference, he can always call .store after creating the struct. It doesn't completely prevent bugs anyway since it is possible for a struct index to be reused the moment it is destroyed, in which case the .create runs at the same game time as .onDestroy did. The only way to properly account for still-running syncs would be to add a .release method to the struct that only calls .destroy after a short delay.

I prefer specifying the initial value. It's fine to have a default value, I just like being explicit in this type of case. Also keep in mind that store is private, because it is not local-context safe. The user would have to sync the initial value in, forcing them to deal with the default value initially.

I do probably want to fix the potential old-sync-affects-new-value problem. I will generate the index from a created count instead of the this index.

*edit* Done. Also solved the potential leaks using the fact that syncing an empty value will flush the entry when the sync comes back.
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 12-08-2010 at 08:13 PM.
Strilanc is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 12-08-2010, 09:30 PM   #17
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Ah, I didn't realize store was just a private method. I would have inlined something so short myself, but I guess it doesn't matter since it will probably get inlined by the map optimizer anyway.

Very well, this looks good, I have no further comments on the code. All this needs now is proper documentation at the start of the library. In the meantime I'll whip together a quick test to ensure it works in practice and once these formalities are out of the way, this can be approved.

Edit: By the way, have you done any testing what happens if you send many simultaneous sync requests (called from the same thread without waits in between)? Will they be received by the host as a single package, ensuring that they get synced at the same game time, or could some of them arrive earlier than others and thus get synced at different game updates?

Also, the current method of avoiding conflicts has the potential to generate many unique strings over time, which is unwanted. I would prefer it if you added delayed recycling of indexes instead. However, doing that with a single timer seems prone to failing if the sync structs get recycled quickly enough for the timer to never expire, while one timer per instance seems like a bit of an overkill. Unless an alternative method of delayed recycling presents itself, I guess the current setup will have to remain.

Edit2: Another though occurs. I imagine you would always want to sync the value from one source player. As such, the syncTo method could take the player as an argument, saving the users the need to do a GetLocalPlayer comparison themselves before calling the method.
__________________

Last edited by Anitarf : 12-09-2010 at 12:35 PM.
Anitarf is offline   Reply With Quote
Old 12-09-2010, 03:17 PM   #18
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Syncs from one player will be applied in the order they are sent. In fact, if the host re-orders actions then the sending player will disconnect immediately. Of course, syncs from multiple players can be swapped due to differences in delay.

I wouldn't worry about the IDs too much. Integer strings are probably used elsewhere in the map and I don't expect maps to be allocating a lot of sync structs anyways.

I'm not going to include a player argument, because any code calling a syncTo is probably already in a local context. For example, you check if data is on the hard disk then read it and sync it. The check makes the sync implicitly local. Chances are the people receiving don't know who is sending.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 12-09-2010, 07:19 PM   #19
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Okay, I ran a test with Deaod using the following code:
Collapse Zinc:
library test
{
    unit cameraFollower[12];
    SyncReal xSynchronizer[12], ySynchronizer[12];
    
    function onPeriodic()
    {
        integer i; for (0<=i<12)
        {
            if (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING)
            {
                SetUnitX(cameraFollower[i], xSynchronizer[i].get());
                SetUnitY(cameraFollower[i], ySynchronizer[i].get());

                if (GetLocalPlayer()==Player(i))
                {
                    xSynchronizer[i].syncTo(GetCameraTargetPositionX());
                    ySynchronizer[i].syncTo(GetCameraTargetPositionY());
                }
            }
        }
    }
    
    function onInit()
    {
        integer i; for (0<=i<12)
        {
            if (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING)
            {
                cameraFollower[i] = CreateUnit(Player(i), 'hfoo', 0.0,0.0,0.0);
                xSynchronizer[i] = SyncReal.create(0.0);
                ySynchronizer[i] = SyncReal.create(0.0);
            }
        }
        TimerStart( CreateTimer(), 0.02, true, function onPeriodic );
    }
}

In singleplayer, the code worked without error and the unit followed the camera position fairly smoothly, although not instantaneously. In multiplayer, the unit's position updated significantly less frequently, about four times per second, which is consistent with the 250ms bnet update time. There was a problem, however, the delay with which the unit responded deteriorated rapidly, suggesting that the host was not able to process such rapid syncs in real time and they were starting to pile up. Reducing the frequency of the timer to 0.1-0.2 fixed that, however the unit movement remained quite a clumsy affair thanks to the delay and the infrequent sync updates.

I'm not sure if the increasing delay we experienced at first only occurs if you try to sync a single gamecache field too rapidly, or if you send too many sync requests in general. This warrants further testing by syncing multiple fields at the 0.1 period.


Quote:
Syncs from one player will be applied in the order they are sent.
That's good, it means something like this should work:
Expand JASS:
The idea is to first start one or multiple syncs, then call SyncWait to ensure all the syncs finish before the callback function runs, the data integer could represent a single SyncType or a linked list/dynamic array of them for ease of access in the callback. If this works, then something like this should be included in the first post as both a useful usage sample as well as a useful functionality extension.
__________________
Anitarf is offline   Reply With Quote
Old 12-09-2010, 08:30 PM   #20
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

The syncs should not 'pile up'. The game would lag to prevent that from happening without bound. To get a better idea of what's happening, you can use replay explorer ( http://www.wc3c.net/showthread.php?t=108962 ), which will show all of the sync actions and make it extremely clear if their arrival-at-host rate matches up with the send rate.

You are correct about the 4 times per second being due to the 250ms tick period. On lan it should be 10 times per second.

I don't think the sync wait will be useful at all. Ok, so the sender knows when the value was finished syncing into game cache. So what? You can't do anything non-local in the callback, since it's specific to the sender. You can't re-sync new values without taking the risk of overwriting the current ones before they are read (eg. syncs to a bot on the same machine with 10ms tick period will be almost instant). What's the use case?
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 12-09-2010, 09:24 PM   #21
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Strilanc
I don't think the sync wait will be useful at all. Ok, so the sender knows when the value was finished syncing into game cache. So what? You can't do anything non-local in the callback, since it's specific to the sender. You can't re-sync new values without taking the risk of overwriting the current ones before they are read (eg. syncs to a bot on the same machine with 10ms tick period will be almost instant). What's the use case?
Not the sender, everyone knows when the sync finished. SyncWait is not meant to be called in a local environment, the idea is to call it globally after .syncTo calls are made locally.
__________________

Last edited by Anitarf : 12-09-2010 at 09:26 PM.
Anitarf is offline   Reply With Quote
Old 12-09-2010, 09:34 PM   #22
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Oh. So you're thinking of the slightly more specific situation where everyone knows a send is happening *now* but not the associated data.

I think just using TriggerSleepAction(0) is sufficient, actually. No need for timers or anything, just store the target in a global and run a trigger that caches the global to a local then TriggerSleepAction(0)'s then calls the cached function pointer.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 12-09-2010, 09:40 PM   #23
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Wouldn't a TriggerSleepAction be insufficient if the sending player lags? What was the smallest wait again, something around 0.2 seconds? The camera-following unit in my test had larger delay than that.
__________________

Last edited by Anitarf : 12-09-2010 at 09:41 PM.
Anitarf is offline   Reply With Quote
Old 12-09-2010, 10:18 PM   #24
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by Anitarf
Wouldn't a TriggerSleepAction be insufficient if the sending player lags? What was the smallest wait again, something around 0.2 seconds? The camera-following unit in my test had larger delay than that.

Right, you're correct. It won't be sufficient. If the sending player lags just before sending the sync, the other players will agree on the end of the wait too soon.

Note: I think a TriggerSleepAction works like this:
Hidden information:
First, the trigger actually sleeps for the desired amount of real time. Once the real time wait is finished, a "WaitFinished" action identifying the trigger thread is sent to the host. On receipt, the host will place the action in the next periodic Tick packet. Once a Tick containing a matching "WaitFinished" action is received (from any source player), the trigger resumes. The game stays synced because Ticks are synced to game times.


I'm not sure if a sync wait will be sufficient either. I guess it might wait for all of them to be received instead of one? Needs testing for sure. But you can still remove the need for timers by starting a new trigger thread and sync waiting there.
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 12-09-2010 at 10:21 PM.
Strilanc is offline   Reply With Quote
Old 12-09-2010, 10:23 PM   #25
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Oh wow, I just remembered. I did tests that showed game cache syncs cause TriggerSleepAction to end immediately. Might be able to use that to make an event!

Kinda wish I had wc3 installed on this computer, and didn't have a paper to write.
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 12-09-2010 at 10:23 PM.
Strilanc is offline   Reply With Quote
Old 12-10-2010, 10:10 AM   #26
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Strilanc
The syncs should not 'pile up'. The game would lag to prevent that from happening without bound. To get a better idea of what's happening, you can use replay explorer ( http://www.wc3c.net/showthread.php?t=108962 ), which will show all of the sync actions and make it extremely clear if their arrival-at-host rate matches up with the send rate.
Regarding this: I don't have time to do more tests, but I can say with certainty that the delay with which the unit followed the camera increased rapidly as the game went on and I have no other explanation for this. Like I said, further tests are warranted, for example having the same number of syncs but on multiple SyncReals instead of on one.
__________________
Anitarf is offline   Reply With Quote
Old 12-12-2010, 05:20 PM   #27
SanKakU
User
 
Join Date: Jan 2009
Posts: 136

SanKakU has a little shameless behaviour in the past (-2)

Send a message via AIM to SanKakU Send a message via MSN to SanKakU Send a message via Yahoo to SanKakU
Default

" For example, maybe one player is a bot that saves a leaderboard and needs to give that information to the others."

HUH?? and why are bots allowed to masquerade as players, anyway? and why are you supporting this seemingly illegal endeavor?
SanKakU is offline   Reply With Quote
Old 12-12-2010, 06:37 PM   #28
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by SanKakU
" For example, maybe one player is a bot that saves a leaderboard and needs to give that information to the others."

HUH?? and why are bots allowed to masquerade as players, anyway? and why are you supporting this seemingly illegal endeavor?

Is this a serious post?

Bots are not illegal or inherently evil. They are useful tools.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 12-12-2010, 08:24 PM   #29
SanKakU
User
 
Join Date: Jan 2009
Posts: 136

SanKakU has a little shameless behaviour in the past (-2)

Send a message via AIM to SanKakU Send a message via MSN to SanKakU Send a message via Yahoo to SanKakU
Default

Quote:
Originally Posted by Strilanc
Is this a serious post?

Bots are not illegal or inherently evil. They are useful tools.
i don't have anything against bots, i simply hate bots that would take a player slot and ruin a game because a bot cannot actually play a game. the bot would steal the slot from the player. i've seen bots do this from time to time. it's thoroughly illegal to be done in the mind of any sensible player.
SanKakU is offline   Reply With Quote
Old 12-12-2010, 10:23 PM   #30
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by SanKakU
i don't have anything against bots, i simply hate bots that would take a player slot and ruin a game because a bot cannot actually play a game. the bot would steal the slot from the player. i've seen bots do this from time to time. it's thoroughly illegal to be done in the mind of any sensible player.

Try not to mix up "illegal" and "wrong". Different, though related.

In the example, I assumed you would realize the leaderboard bot is an intended part of the map. It is not taking up a player slot, it is taking up a special slot provided for it that would normally have a computer. It would be included by the host, not join random games.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 12:48 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services