~armagetronad-ap/armagetronad/BattleMania

« back to all changes in this revision

Viewing changes to src/network/sync.php

  • Committer: zodiacsohma1 at gmail
  • Date: 2014-03-02 08:09:55 UTC
  • Revision ID: zodiacsohma1@gmail.com-20140302080955-r5ot6eipfe0nlpww
Simplified all fields and code in all areas for better as they seem to repeat themselves.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
function OnlineSyncDetails()
11
11
{
12
 
    $synched  = false;
 
12
    $sync_done  = false;
13
13
    $sync_msg = "";
14
14
 
15
15
    //debugExecute("Syncing script with server...");
24
24
        if ($humans != Base::$base->humans)
25
25
        {
26
26
            Base::$base->humans = $humans;
27
 
            $synched =  true;
 
27
            $sync_done =  true;
28
28
            $sync_msg = "Updated humans count";
29
29
        }
30
30
 
31
31
        if ($ais != Base::$base->ais)
32
32
        {
33
33
            Base::$base->ais = $ais;
34
 
            $synched  = true;
 
34
            $sync_done  = true;
35
35
            $sync_msg = "Updated ais count";
36
36
        }
37
37
 
45
45
        if ($a_alive != Base::$base->ai_alive)
46
46
        {
47
47
            Base::$base->ai_alive = $a_alive;
48
 
            $synched  = true;
 
48
            $sync_done  = true;
49
49
            $sync_msg = "Updated ai alive count";
50
50
        }
51
51
    }
56
56
        {
57
57
            $player = Base::$base->pieces[$i];
58
58
            $p = getPlayerByLog($player);
59
 
            if (isset($p) && !is_null($p) && $p instanceof Player)
 
59
            if (isset($p) && $p instanceof Player)
60
60
            {
61
 
                if (isset($p->cycle) && !is_null($p->cycle) && $p->cycle instanceof Cycle)
 
61
                if (isset($p->cycle) && $p->cycle instanceof Cycle)
62
62
                {
63
63
                    if (!$p->cycle->alive)
64
64
                    {
65
65
                        $p->cycle->alive = true;
66
 
                        $synched  = true;
 
66
                        $sync_done  = true;
67
67
                        $sync_msg = "Set the cycle for ".$p." to alive";
68
68
                    }
69
69
                }
71
71
                {
72
72
                    new Cycle(new Coord(), new Coord(), $p, $p->team);
73
73
 
74
 
                    $synched  = true;
 
74
                    $sync_done  = true;
75
75
                    $sync_msg = "Created new cycle for ".$p;
76
76
                }
77
77
            }
93
93
        {
94
94
            $player = Base::$base->pieces[$i];
95
95
            $p = getPlayerByLog($player);
96
 
            if (isset($p) && !is_null($p) && $p instanceof Player)
 
96
            if (isset($p) && $p instanceof Player)
97
97
            {
98
 
                if (isset($p->cycle) && !is_null($p->cycle) && $p->cycle instanceof Cycle)
 
98
                if (isset($p->cycle) && $p->cycle instanceof Cycle)
99
99
                {
100
100
                    if ($p->cycle->alive)
101
101
                    {
102
102
                        $p->cycle->alive = false;
103
103
 
104
 
                        $synched  = true;
 
104
                        $sync_done  = true;
105
105
                        $sync_msg = "Set the cycle for ".$p." to dead";
106
106
                    }
107
107
                }
109
109
        }
110
110
    }
111
111
 
112
 
    if ($synched)
 
112
    if ($sync_done)
113
113
        debugExecute("0xaa77aaScript Sync: 0x77ff22".$sync_msg);
114
114
}