Skip to content

Commit

Permalink
Consistency - Use english variant of "Defence"
Browse files Browse the repository at this point in the history
  • Loading branch information
thekabal committed Jul 4, 2016
1 parent 5cb9ebe commit 8567591
Show file tree
Hide file tree
Showing 45 changed files with 285 additions and 285 deletions.
6 changes: 3 additions & 3 deletions attack.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// or it will fail to log the sql.
$result = $db->Execute(
"LOCK TABLES {$db->prefix}adodb_logsql WRITE, {$db->prefix}languages READ, " .
"{$db->prefix}ibank_accounts READ, {$db->prefix}sector_defence WRITE, " .
"{$db->prefix}ibank_accounts READ, {$db->prefix}sector_defense WRITE, " .
"{$db->prefix}ships WRITE, {$db->prefix}universe WRITE, {$db->prefix}bounty WRITE, " .
"{$db->prefix}zones READ, {$db->prefix}planets WRITE, " .
"{$db->prefix}news WRITE, {$db->prefix}movement_log WRITE, {$db->prefix}logs WRITE;"
Expand Down Expand Up @@ -179,7 +179,7 @@
Tki\PlayerLog::WriteLog($pdo_db, $targetinfo['ship_id'], LOG_ATTACK_EWD, "$playerinfo[character_name]");
$result_warp = $db->Execute(
"UPDATE {$db->prefix}ships SET sector = $dest_sector, " .
"dev_emerwarp = dev_emerwarp - 1, cleared_defences = ' ' " .
"dev_emerwarp = dev_emerwarp - 1, cleared_defenses = ' ' " .
"WHERE ship_id = ?;",
array($targetinfo['ship_id'])
);
Expand Down Expand Up @@ -617,7 +617,7 @@
"UPDATE {$db->prefix}ships SET hull = 0, engines = 0, power = 0, sensors = 0, computer = 0, beams = 0, torp_launchers = 0, " .
"torps = 0, armor = 0, armor_pts = 100, cloak = 0, shields = 0, sector = 0, ship_organics = 0, ship_ore = 0, ship_goods = 0, " .
"ship_energy = ?, ship_colonists = 0, ship_fighters = 100, dev_warpedit = 0, dev_genesis = 0, dev_beacon = 0, dev_emerwarp = 0, " .
"dev_escapepod = 'N', dev_fuelscoop = 'N', dev_minedeflector = 0, on_planet = 'N', rating = ?, cleared_defences = ' ', " .
"dev_escapepod = 'N', dev_fuelscoop = 'N', dev_minedeflector = 0, on_planet = 'N', rating = ?, cleared_defenses = ' ', " .
"dev_lssd = 'N' WHERE ship_id = ?;",
array($tkireg->start_energy, $rating, $targetinfo['ship_id'])
);
Expand Down
38 changes: 19 additions & 19 deletions check_fighters.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
$stmt->execute();
$sectorinfo = $stmt->fetch(PDO::FETCH_ASSOC);

$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id = ? and defence_type ='F' ORDER BY quantity DESC;", array($sector));
$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? and defense_type ='F' ORDER BY quantity DESC;", array($sector));
Tki\Db::LogDbErrors($pdo_db, $result3, __LINE__, __FILE__);

// Put the defence information into the array "defences"
// Put the defense information into the array "defenses"
$i = 0;
$total_sector_fighters = 0;
$owner = true;
Expand Down Expand Up @@ -63,22 +63,22 @@
while (!$result3->EOF)
{
$row = $result3->fields;
$defences[$i] = $row;
$total_sector_fighters += $defences[$i]['quantity'];
if ($defences[$i]['ship_id'] != $playerinfo['ship_id'])
$defenses[$i] = $row;
$total_sector_fighters += $defenses[$i]['quantity'];
if ($defenses[$i]['ship_id'] != $playerinfo['ship_id'])
{
$owner = false;
}
$i++;
$result3->MoveNext();
}

$num_defences = $i;
if ($num_defences > 0 && $total_sector_fighters > 0 && !$owner)
$num_defenses = $i;
if ($num_defenses > 0 && $total_sector_fighters > 0 && !$owner)
{
// Find out if the fighter owner and player are on the same team
// All sector defences must be owned by members of the same team
$fm_owner = $defences[0]['ship_id'];
// All sector defenses must be owned by members of the same team
$fm_owner = $defenses[0]['ship_id'];
$result2 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id = ?;", array($fm_owner));
Tki\Db::LogDbErrors($pdo_db, $result2, __LINE__, __FILE__);
$fighters_owner = $result2->fields;
Expand All @@ -87,14 +87,14 @@
switch ($response)
{
case "fight":
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defences = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__);
echo "<h1>" . $title . "</h1>\n";
include_once './sector_fighters.php';
break;

case "retreat":
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defences = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__);
$stamp = date("Y-m-d H:i:s");
$resx = $db->Execute("UPDATE {$db->prefix}ships SET last_login='$stamp', turns = turns - 2, turns_used = turns_used + 2, sector=? WHERE ship_id=?;", array($playerinfo['sector'], $playerinfo['ship_id']));
Expand All @@ -105,7 +105,7 @@
die();

case "pay":
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defences = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__);
$fighterstoll = $total_sector_fighters * $fighter_price * 0.6;
if ($playerinfo['credits'] < $fighterstoll)
Expand All @@ -131,7 +131,7 @@
break;

case "sneak":
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defences = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id']));
Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__);
$success = Tki\Scan::success($fighters_owner['sensors'], $playerinfo['cloak']);
if ($success < 5)
Expand All @@ -145,37 +145,37 @@
$roll = random_int(1, 100);
if ($roll < $success)
{
// Sector defences detect incoming ship
// Sector defenses detect incoming ship
echo "<h1>" . $title . "</h1>\n";
echo $langvars['l_chf_thefightersdetectyou'] . "<br>";
include_once './sector_fighters.php';
break;
}
else
{
// Sector defences don't detect incoming ship
// Sector defenses don't detect incoming ship
$ok = 1;
}
break;

default:
$interface_string = $calledfrom . '?sector=' . $sector . '&destination=' . $destination . '&engage=' . $engage;
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defences = ? WHERE ship_id = ?;", array($interface_string, $playerinfo['ship_id']));
$resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ? WHERE ship_id = ?;", array($interface_string, $playerinfo['ship_id']));
Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__);
$fighterstoll = $total_sector_fighters * $fighter_price * 0.6;
echo "<h1>" . $title . "</h1>\n";
echo "<form accept-charset='utf-8' action='{$calledfrom}' method='post'>";
$langvars['l_chf_therearetotalfightersindest'] = str_replace("[chf_total_sector_fighters]", $total_sector_fighters, $langvars['l_chf_therearetotalfightersindest']);
echo $langvars['l_chf_therearetotalfightersindest'] . "<br>";
if ($defences[0]['fm_setting'] == "toll")
if ($defenses[0]['fm_setting'] == "toll")
{
$langvars['l_chf_creditsdemanded'] = str_replace("[chf_number_fighterstoll]", number_format($fighterstoll, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']), $langvars['l_chf_creditsdemanded']);
echo $langvars['l_chf_creditsdemanded'] . "<br>";
}

$langvars['l_chf_youcanretreat'] = str_replace("[retreat]", "<strong>Retreat</strong>", $langvars['l_chf_youcanretreat']);
echo $langvars['l_chf_youcan'] . " <br><input type='radio' name='response' value='retreat'>" . $langvars['l_chf_youcanretreat'] . "<br></input>";
if ($defences[0]['fm_setting'] == "toll")
if ($defenses[0]['fm_setting'] == "toll")
{
$langvars['l_chf_inputpay'] = str_replace("[pay]", "<strong>Pay</strong>", $langvars['l_chf_inputpay']);
echo "<input type='radio' name='response' checked value='pay'>" . $langvars['l_chf_inputpay'] . "<br></input>";
Expand All @@ -198,7 +198,7 @@

}
// Clean up any sectors that have used up all mines or fighters
$resx = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE quantity <= 0 ");
$resx = $db->Execute("DELETE FROM {$db->prefix}sector_defense WHERE quantity <= 0 ");
Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__);
}
}
20 changes: 10 additions & 10 deletions check_mines.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@
$stmt->execute();
$sectorinfo = $stmt->fetch(PDO::FETCH_ASSOC);

// Put the defence information into the array "defenceinfo"
$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id = ? and defence_type ='M'", array($sector));
// Put the defense information into the array "defenseinfo"
$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? and defense_type ='M'", array($sector));
Tki\Db::LogDbErrors($pdo_db, $result3, __LINE__, __FILE__);

// Correct the targetship bug to reflect the player info
$targetship = $playerinfo;

$num_defences = 0;
$num_defenses = 0;
$total_sector_mines = 0;
$owner = true;
while (!$result3->EOF)
{
$row = $result3->fields;
$defences[$num_defences] = $row;
$total_sector_mines += $defences[$num_defences]['quantity'];
if ($defences[$num_defences]['ship_id'] != $playerinfo['ship_id'])
$defenses[$num_defenses] = $row;
$total_sector_mines += $defenses[$num_defenses]['quantity'];
if ($defenses[$num_defenses]['ship_id'] != $playerinfo['ship_id'])
{
$owner = false;
}
$num_defences++;
$num_defenses++;
$result3->MoveNext();
}

Expand All @@ -64,10 +64,10 @@
// 3) You are not the owner or on the team of the owner - team 0 dosent count
// 4) You ship is at least $tkireg->mine_hullsize (setable in config/classic_config.ini.php) big

if ($num_defences > 0 && $total_sector_mines > 0 && !$owner && $shipavg > $tkireg->mine_hullsize)
if ($num_defenses > 0 && $total_sector_mines > 0 && !$owner && $shipavg > $tkireg->mine_hullsize)
{
// Find out if the mine owner and player are on the same team
$fm_owner = $defences[0]['ship_id'];
$fm_owner = $defenses[0]['ship_id'];
$result2 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id = ?;", array($fm_owner));
Tki\Db::LogDbErrors($pdo_db, $result2, __LINE__, __FILE__);

Expand Down Expand Up @@ -166,7 +166,7 @@
{
$rating = round($playerinfo['rating'] / 2);
echo $langvars['l_chm_luckescapepod'] . "<br><br>";
$resx = $db->Execute("UPDATE {$db->prefix}ships SET hull=0, engines=0, power=0, sensors=0, computer=0, beams=0, torp_launchers=0, torps=0, armor=0, armor_pts=100, cloak=0, shields=0, sector=0, ship_organics=0, ship_ore=0, ship_goods=0, ship_energy=?, ship_colonists=0, ship_fighters=100, dev_warpedit=0, dev_genesis=0, dev_beacon=0, dev_emerwarp=0, dev_escapepod='N', dev_fuelscoop='N', dev_minedeflector=0, on_planet='N', rating=?, cleared_defences=' ', dev_lssd='N' WHERE ship_id=?", array($tkireg->start_energy, $rating, $playerinfo['ship_id']));
$resx = $db->Execute("UPDATE {$db->prefix}ships SET hull=0, engines=0, power=0, sensors=0, computer=0, beams=0, torp_launchers=0, torps=0, armor=0, armor_pts=100, cloak=0, shields=0, sector=0, ship_organics=0, ship_ore=0, ship_goods=0, ship_energy=?, ship_colonists=0, ship_fighters=100, dev_warpedit=0, dev_genesis=0, dev_beacon=0, dev_emerwarp=0, dev_escapepod='N', dev_fuelscoop='N', dev_minedeflector=0, on_planet='N', rating=?, cleared_defenses=' ', dev_lssd='N' WHERE ship_id=?", array($tkireg->start_energy, $rating, $playerinfo['ship_id']));
Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__);
Tki\Bounty::cancel($pdo_db, $db, $playerinfo['ship_id']);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Character
{
public static function kill(\PDO $pdo_db, $db, $ship_id, $langvars, Reg $tkireg, $remove_planets = false)
{
$update_ships_res = $db->Execute("UPDATE {$db->prefix}ships SET ship_destroyed='Y', on_planet='N', sector=0, cleared_defences=' ' WHERE ship_id=?", array($ship_id));
$update_ships_res = $db->Execute("UPDATE {$db->prefix}ships SET ship_destroyed='Y', on_planet='N', sector=0, cleared_defenses=' ' WHERE ship_id=?", array($ship_id));
Db::LogDbErrors($pdo_db, $update_ships_res, __LINE__, __FILE__);

$delete_bounty_res = $db->Execute("DELETE FROM {$db->prefix}bounty WHERE placed_by = ?", array($ship_id));
Expand Down Expand Up @@ -54,7 +54,7 @@ public static function kill(\PDO $pdo_db, $db, $ship_id, $langvars, Reg $tkireg,
}
}

$rm_def_res = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE ship_id=?", array($ship_id));
$rm_def_res = $db->Execute("DELETE FROM {$db->prefix}sector_defense WHERE ship_id=?", array($ship_id));
Db::LogDbErrors($pdo_db, $rm_def_res, __LINE__, __FILE__);

$zone_res = $db->Execute("SELECT zone_id FROM {$db->prefix}zones WHERE team_zone='N' AND owner=?", array($ship_id));
Expand Down
20 changes: 10 additions & 10 deletions classes/Defense.php → classes/Defence.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@

class Defense
{
public static function defenceVsDefence(\PDO $pdo_db, $db, $ship_id, $langvars)
public static function defenseVsDefense(\PDO $pdo_db, $db, $ship_id, $langvars)
{
$secdef_result = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE ship_id = ?;", array($ship_id));
$secdef_result = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE ship_id = ?;", array($ship_id));
Db::LogDbErrors($pdo_db, $secdef_result, __LINE__, __FILE__);

if ($secdef_result instanceof \adodb\ADORecordSet)
{
while (!$secdef_result->EOF)
{
$row = $secdef_result->fields;
$deftype = $row['defence_type'] == 'F' ? 'Fighters' : 'Mines';
$deftype = $row['defense_type'] == 'F' ? 'Fighters' : 'Mines';
$qty = $row['quantity'];
$other_secdef_res = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id = ? AND ship_id <> ? ORDER BY quantity DESC", array($row['sector_id'], $ship_id));
$other_secdef_res = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? AND ship_id <> ? ORDER BY quantity DESC", array($row['sector_id'], $ship_id));
Db::LogDbErrors($pdo_db, $other_secdef_res, __LINE__, __FILE__);
if ($other_secdef_res instanceof \adodb\ADORecordSet)
{
while (!$other_secdef_res->EOF && $qty > 0)
{
$cur = $other_secdef_res->fields;
$targetdeftype = $cur['defence_type'] == 'F' ? $langvars['l_fighters'] : $langvars['l_mines'];
$targetdeftype = $cur['defense_type'] == 'F' ? $langvars['l_fighters'] : $langvars['l_mines'];
if ($qty > $cur['quantity'])
{
$del_secdef_res = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE defence_id = ?", array($cur['defence_id']));
$del_secdef_res = $db->Execute("DELETE FROM {$db->prefix}sector_defense WHERE defense_id = ?", array($cur['defense_id']));
Db::LogDbErrors($pdo_db, $del_secdef_res, __LINE__, __FILE__);
$qty -= $cur['quantity'];
$up_secdef_res = $db->Execute("UPDATE {$db->prefix}sector_defence SET quantity = ? WHERE defence_id = ?", array($qty, $row['defence_id']));
$up_secdef_res = $db->Execute("UPDATE {$db->prefix}sector_defense SET quantity = ? WHERE defense_id = ?", array($qty, $row['defense_id']));
Db::LogDbErrors($pdo_db, $up_secdef_res, __LINE__, __FILE__);
PlayerLog::WriteLog($pdo_db, $cur['ship_id'], LOG_DEFS_DESTROYED, $cur['quantity'] .'|'. $targetdeftype .'|'. $row['sector_id']);
PlayerLog::WriteLog($pdo_db, $row['ship_id'], LOG_DEFS_DESTROYED, $cur['quantity'] .'|'. $deftype .'|'. $row['sector_id']);
}
else
{
$del_secdef_res2 = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE defence_id = ?", array($row['defence_id']));
$del_secdef_res2 = $db->Execute("DELETE FROM {$db->prefix}sector_defense WHERE defense_id = ?", array($row['defense_id']));
Db::LogDbErrors($pdo_db, $del_secdef_res2, __LINE__, __FILE__);

$up_secdef_res2 = $db->Execute("UPDATE {$db->prefix}sector_defence SET quantity=quantity - ? WHERE defence_id = ?", array($qty, $cur['defence_id']));
$up_secdef_res2 = $db->Execute("UPDATE {$db->prefix}sector_defense SET quantity=quantity - ? WHERE defense_id = ?", array($qty, $cur['defense_id']));
Db::LogDbErrors($pdo_db, $up_secdef_res2, __LINE__, __FILE__);
PlayerLog::WriteLog($pdo_db, $cur['ship_id'], LOG_DEFS_DESTROYED, $qty .'|'. $targetdeftype .'|'. $row['sector_id']);
PlayerLog::WriteLog($pdo_db, $row['ship_id'], LOG_DEFS_DESTROYED, $qty .'|'. $deftype .'|'. $row['sector_id']);
Expand All @@ -67,7 +67,7 @@ public static function defenceVsDefence(\PDO $pdo_db, $db, $ship_id, $langvars)
}
$secdef_result->MoveNext();
}
$del_secdef_res3 = $db->Execute("DELETE FROM {$db->prefix}sector_defence WHERE quantity <= 0");
$del_secdef_res3 = $db->Execute("DELETE FROM {$db->prefix}sector_defense WHERE quantity <= 0");
Db::LogDbErrors($pdo_db, $del_secdef_res3, __LINE__, __FILE__);
}
}
Expand Down
Loading

0 comments on commit 8567591

Please sign in to comment.