Exemplo n.º 1
0
function collect_credits($planetarray)
{
  global $db, $dbtables, $username;

  $CS = "GO"; // Current State

  // create an array of sector -> planet pairs
  for($i = 0; $i < count($planetarray); $i++)
  {
    $res = $db->Execute("SELECT * FROM $dbtables[planets] WHERE planet_id=$planetarray[$i]");
    $s_p_pair[$i]= array($res->fields["sector_id"], $planetarray[$i]);
  }

  // Sort the array so that it is in order of sectors, lowest number first, not closest
  sort($s_p_pair);
  reset($s_p_pair);

  // run through the list of sector planet pairs realspace moving to each sector and then performing the transfer. 
  // Based on the way realspace works we don't need a sub loop -- might add a subloop to clean things up later.


  for($i=0; $i < count($planetarray) && $CS == "GO"; $i++)
  {
    echo "<BR>";
    $CS = Real_space_move($s_p_pair[$i][0]);
	if ($CS != "ON_PLANET") {
		if ($CS == "HOSTILE")
		{
		$CS = "GO";
		} else if($CS == "GO")
		{
		  $CS = Take_Credits($s_p_pair[$i][0], $s_p_pair[$i][1]);
		}
		else
		 echo "<BR> NOT ENOUGH TURNS TO TAKE CREDITS<BR>";
	}
    echo "<BR>";
  }

  if($CS != "GO" && $CS != "HOSTILE" && $CS != "ON_PLANET")
  {
    echo "<BR>Not enough turns to complete credit collection<BR>";
  }

  echo "<BR>";
  echo "Click <A HREF=planet-report.php?PRepType=1>here</A> to return to the Planet Status Report<br>";
}
Exemplo n.º 2
0
function collect_credits($planetarray)
{
    global $db, $username, $sector_max;
    global $db_logging;
    $CS = "GO";
    // Current State
    // Look up Player info that wants to collect the credits.
    $result1 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id='{$user_ship_id}' LIMIT 1");
    db_op_result($db, $result1, __LINE__, __FILE__, $db_logging);
    $playerinfo = $result1->fields;
    // Set var as an Array.
    $s_p_pair = array();
    // create an array of sector -> planet pairs
    for ($i = 0; $i < count($planetarray); $i++) {
        $res = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id={$planetarray[$i]};");
        db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
        // Only add to array if the Player owns the Planet.
        if ($res->fields['owner'] == $playerinfo['ship_id'] && $res->fields['sector_id'] < $sector_max) {
            $s_p_pair[$i] = array($res->fields['sector_id'], $planetarray[$i]);
        } else {
            $hack_id = 20100401;
            $ip = $_SERVER['REMOTE_ADDR'];
            $planet_id = $res->fields['planet_id'];
            $sector_id = $res->fields['sector_id'];
            adminlog($db, LOG_ADMIN_PLANETCHEAT, "{$hack_id}|{$ip}|{$planet_id}|{$sector_id}|{$playerinfo['ship_id']}");
            break;
        }
    }
    // Sort the array so that it is in order of sectors, lowest number first, not closest
    sort($s_p_pair);
    reset($s_p_pair);
    // run through the list of sector planet pairs realspace moving to each sector and then performing the transfer.
    // Based on the way realspace works we don't need a sub loop -- might add a subloop to clean things up later.
    for ($i = 0; $i < count($s_p_pair) && $CS == "GO"; $i++) {
        echo "<br>";
        $CS = Real_space_move($s_p_pair[$i][0]);
        if ($CS == "HOSTILE") {
            $CS = "GO";
        } else {
            if ($CS == "GO") {
                $CS = Take_Credits($s_p_pair[$i][0], $s_p_pair[$i][1]);
            } else {
                echo "<br> NOT ENOUGH TURNS TO TAKE CREDITS<br>";
            }
        }
        echo "<br>";
    }
    if ($CS != "GO" && $CS != "HOSTILE") {
        echo "<br>Not enough turns to complete credit collection<br>";
    }
    echo "<br>";
    echo "Click <a href=planet_report.php?PRepType=1>here</A> to return to the Planet Status Report<br>";
}