~armagetronad-ap/armagetronad/BattleMania

« back to all changes in this revision

Viewing changes to src/engine/main.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:
8
8
###################################################################
9
9
 
10
10
//!<  Reads the STDIN (input) from feed provided by the stream
11
 
function ReadStdin()
 
11
function ReadStdin($stream_in)
12
12
{
13
13
    //  Normally use rtrim but trim is better for this.
14
14
    //  Extended read line length from 1024 to 2048 for long lines.
15
 
    Base::$base->line = trim(fgets(STDIN, 2048));
 
15
    Base::$base->line = trim(fgets($stream_in, 2048));
16
16
}
17
17
 
18
18
//!< Put the pieces together
35
35
}
36
36
 
37
37
//!< MAIN ENGINE >!\\
38
 
function main()
 
38
function main($stream_in)
39
39
{
 
40
    //  Normally use rtrim but trim is better for this!
 
41
    ReadStdin($stream_in);
 
42
 
40
43
    //  parse lines read
41
44
    if (Filter(Base::$base->line) !== "")
42
45
    {
128
131
                if (Base::$base->game_mode == 1) return;
129
132
 
130
133
                $player = getPlayerByLog(Base::$base->pieces[1]);
131
 
                if (isset($player) && !is_null($player) && $player instanceof Player)
 
134
                if (isset($player) && $player instanceof Player)
132
135
                {
133
136
                    $cycle = $player->cycle;
134
 
                    if (isset($cycle) && !is_null($cycle) && $cycle instanceof Cycle)
 
137
                    if (isset($cycle) && $cycle instanceof Cycle)
135
138
                    {
136
139
                        $pos = new Coord(Base::$base->pieces[2] / Base::$base->ARENA->sizeMultiplier, Base::$base->pieces[3] / Base::$base->ARENA->sizeMultiplier);
137
140
                        $dir = new Coord(Base::$base->pieces[4], Base::$base->pieces[5]);