1 | <?php |
---|
2 | // for easier patching |
---|
3 | |
---|
4 | // Note: DO UPDATES ALWAYS OVER THE ITEM NAMES, SO NO KB's |
---|
5 | // DATABASES GET SCREWED UP. |
---|
6 | // |
---|
7 | // |
---|
8 | if (!config::get("DBUpdate")) |
---|
9 | config::set("DBUpdate","000"); |
---|
10 | |
---|
11 | // Current update version of Database |
---|
12 | define(CURRENT_DB_UPDATE,config::get("DBUpdate")); |
---|
13 | //Update version of this autoupgrade.php |
---|
14 | define(LASTEST_DB_UPDATE,"004"); |
---|
15 | |
---|
16 | function updateDB(){ |
---|
17 | // if update nesseary run updates |
---|
18 | if (CURRENT_DB_UPDATE < LASTEST_DB_UPDATE ){ |
---|
19 | update001(); |
---|
20 | update002(); |
---|
21 | update003(); |
---|
22 | update004(); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | function update001(){ |
---|
27 | //Checking if this Update already done |
---|
28 | if (CURRENT_DB_UPDATE < "001" ) |
---|
29 | { |
---|
30 | require_once("common/includes/class.item.php"); |
---|
31 | // Changing ShieldBooster Slot from None to Mid Slot |
---|
32 | $ShieldBoosterGroup = item::get_group_id("Small Shield Booster I"); |
---|
33 | update_slot_of_group($ShieldBoosterGroup,0,2); |
---|
34 | |
---|
35 | // Changing Tracking Scripts Slot from None to Mid Slot |
---|
36 | $ScriptGroupID1 = item::get_group_id("Optimal Range"); |
---|
37 | update_slot_of_group($ScriptGroupID1,0,2); |
---|
38 | |
---|
39 | // Changing Warp Disruption Scripts Slot from None to Mid Slot |
---|
40 | $ScriptGroupID2 = item::get_group_id("Focused Warp Disruption"); |
---|
41 | update_slot_of_group($ScriptGroupID2,0,2); |
---|
42 | |
---|
43 | // Changing Tracking Disruption Scripts Slot from None to Mid Slot |
---|
44 | $ScriptGroupID3 = item::get_group_id("Optimal Range Disruption"); |
---|
45 | update_slot_of_group($ScriptGroupID3,0,2); |
---|
46 | |
---|
47 | // Changing Sensor Booster Scripts Slot from None to Mid Slot |
---|
48 | $ScriptGroupID4 = item::get_group_id("Targeting Range"); |
---|
49 | update_slot_of_group($ScriptGroupID4,0,2); |
---|
50 | |
---|
51 | // Changing Sensor Dampener Scripts Slot from None to Mid Slot |
---|
52 | $ScriptGroupID5 = item::get_group_id("Scan Resolution Dampening"); |
---|
53 | update_slot_of_group($ScriptGroupID5,0,2); |
---|
54 | |
---|
55 | // Changing Energy Weapon Slot from None to High Slot |
---|
56 | $EnergyWeaponGroup = item::get_group_id("Gatling Pulse Laser I"); |
---|
57 | update_slot_of_group($EnergyWeaponGroup,0,1); |
---|
58 | |
---|
59 | // Changing Group of Salvager I to same as Small Tractor Beam I |
---|
60 | $item = new Item(); |
---|
61 | $item->lookup("Salvager I"); |
---|
62 | $SalvagerTypeId = $item->getId(); |
---|
63 | $SalvagerGroup = item::get_group_id("Salvager I"); |
---|
64 | $TractorBeam = item::get_group_id("Small Tractor Beam I"); |
---|
65 | move_item_to_group($SalvagerTypeId,$SalvagerGroup ,$TractorBeam); |
---|
66 | |
---|
67 | //writing Update Status into ConfigDB |
---|
68 | config::set("DBUpdate","001"); |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | function update002(){ |
---|
73 | // to correct the already existing Salvager in med slots. |
---|
74 | // missed it in update001 |
---|
75 | if (CURRENT_DB_UPDATE < "002" ) |
---|
76 | { |
---|
77 | require_once("common/includes/class.item.php"); |
---|
78 | $SalvagerGroup = item::get_group_id("Salvager I"); |
---|
79 | update_slot_of_group($SalvagerGroup,2,1); |
---|
80 | config::set("DBUpdate","002"); |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | function update003(){ |
---|
85 | // Warefare Links and Command Prozessor were midslot items in install file, should be high slot |
---|
86 | if (CURRENT_DB_UPDATE < "003" ) |
---|
87 | { |
---|
88 | require_once("common/includes/class.item.php"); |
---|
89 | $WarfareLinkGroup = item::get_group_id("Skirmish Warfare Link - Rapid Deployment"); |
---|
90 | update_slot_of_group($WarfareLinkGroup,2,1); |
---|
91 | config::set("DBUpdate","003"); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | function update004(){ |
---|
96 | // new trinity ships are wrong saved as T1 shipes |
---|
97 | if (CURRENT_DB_UPDATE < "004" ) |
---|
98 | { |
---|
99 | $qry = new DBQuery(); |
---|
100 | |
---|
101 | $query = "UPDATE kb3_ships |
---|
102 | INNER JOIN kb3_ship_classes ON scl_id = shp_class |
---|
103 | SET shp_techlevel = 2 |
---|
104 | WHERE scl_class IN ('Electronic Attack Ship','Heavy Interdictor','Black Ops','Marauder','Heavy Interdictor','Jump Freighter') |
---|
105 | AND shp_techlevel = 1;"; |
---|
106 | $qry->execute($query); |
---|
107 | config::set("DBUpdate","004"); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | function update_slot_of_group($id,$oldSlot = 0 ,$newSlot){ |
---|
112 | $qry = new DBQuery(); |
---|
113 | $query = "UPDATE kb3_item_types |
---|
114 | SET itt_slot = $newSlot WHERE itt_id = $id and itt_slot = $oldSlot;"; |
---|
115 | $qry->execute($query); |
---|
116 | $query = "UPDATE kb3_items_destroyed |
---|
117 | INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID |
---|
118 | SET itd_itl_id = $newSlot |
---|
119 | WHERE itd_itl_id = $oldSlot;"; |
---|
120 | $qry->execute($query); |
---|
121 | |
---|
122 | $query = "UPDATE kb3_items_dropped |
---|
123 | INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID |
---|
124 | SET itd_itl_id = $newSlot |
---|
125 | WHERE itd_itl_id = $oldSlot;"; |
---|
126 | $qry->execute($query); |
---|
127 | } |
---|
128 | |
---|
129 | function move_item_to_group($id,$oldGroup ,$newGroup){ |
---|
130 | $qry = new DBQuery(); |
---|
131 | $query = "UPDATE kb3_invtypes |
---|
132 | SET groupID = $newGroup |
---|
133 | WHERE typeID = $id AND groupID = $oldGroup;"; |
---|
134 | $qry->execute($query); |
---|
135 | } |
---|
136 | |
---|
137 | ?> |
---|