root/dev/common/includes/autoupgrade.php @ 355

Revision 355, 7.9 KB (checked in by beans, 14 years ago)

* Added blueprint icons to the img folder and to template.
* Autoupgrade updated, updates blueprint info. Go to admin->Database to run it.
Thanks to EDG for these fixes

Line 
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//
8if (!config::get("DBUpdate"))
9        config::set("DBUpdate","000");
10       
11// Current update version of Database
12define(CURRENT_DB_UPDATE,config::get("DBUpdate"));
13//Update version of this autoupgrade.php
14define(LASTEST_DB_UPDATE,"005");
15
16function updateDB(){
17        // if update nesseary run updates
18        if (CURRENT_DB_UPDATE < LASTEST_DB_UPDATE ){
19                update001();
20                update002();
21                update003();
22                update004();
23                update005();
24        }
25}
26
27function update001(){
28        //Checking if this Update already done
29        if (CURRENT_DB_UPDATE < "001" )
30        {
31                require_once("common/includes/class.item.php");
32                // Changing ShieldBooster Slot from None to Mid Slot
33                $ShieldBoosterGroup = item::get_group_id("Small Shield Booster I");
34                update_slot_of_group($ShieldBoosterGroup,0,2);
35               
36                // Changing Tracking Scripts Slot from None to Mid Slot
37                $ScriptGroupID1 = item::get_group_id("Optimal Range");
38                update_slot_of_group($ScriptGroupID1,0,2);
39
40                // Changing Warp Disruption Scripts Slot from None to Mid Slot
41                $ScriptGroupID2 = item::get_group_id("Focused Warp Disruption");
42                update_slot_of_group($ScriptGroupID2,0,2);
43               
44                // Changing Tracking Disruption Scripts Slot from None to Mid Slot
45                $ScriptGroupID3 = item::get_group_id("Optimal Range Disruption");
46                update_slot_of_group($ScriptGroupID3,0,2);
47               
48                // Changing Sensor Booster Scripts Slot from None to Mid Slot
49                $ScriptGroupID4 = item::get_group_id("Targeting Range");
50                update_slot_of_group($ScriptGroupID4,0,2);
51               
52                // Changing Sensor Dampener Scripts Slot from None to Mid Slot
53                $ScriptGroupID5 = item::get_group_id("Scan Resolution Dampening");
54                update_slot_of_group($ScriptGroupID5,0,2);
55               
56                // Changing Energy Weapon Slot from None to High Slot
57                $EnergyWeaponGroup = item::get_group_id("Gatling Pulse Laser I");
58                update_slot_of_group($EnergyWeaponGroup,0,1);
59               
60                // Changing Group of Salvager I to same as Small Tractor Beam I         
61                $item = new Item();
62                $item->lookup("Salvager I");
63                $SalvagerTypeId =  $item->getId();
64                $SalvagerGroup  =  item::get_group_id("Salvager I");
65                $TractorBeam    =  item::get_group_id("Small Tractor Beam I"); 
66                move_item_to_group($SalvagerTypeId,$SalvagerGroup ,$TractorBeam);
67       
68                //writing Update Status into ConfigDB
69                config::set("DBUpdate","001"); 
70        }
71}
72
73function update002(){
74        // to correct the already existing Salvager in med slots.
75        // missed it in update001
76        if (CURRENT_DB_UPDATE < "002" )
77        {
78                require_once("common/includes/class.item.php");
79                $SalvagerGroup  =  item::get_group_id("Salvager I");
80                update_slot_of_group($SalvagerGroup,2,1);
81                config::set("DBUpdate","002"); 
82        }
83}
84
85function update003(){
86        // Warefare Links and Command Prozessor were midslot items in install file, should be high slot
87        if (CURRENT_DB_UPDATE < "003" )
88        {
89                require_once("common/includes/class.item.php");
90                $WarfareLinkGroup  =  item::get_group_id("Skirmish Warfare Link - Rapid Deployment");
91                update_slot_of_group($WarfareLinkGroup,2,1);
92                config::set("DBUpdate","003"); 
93        }
94}
95
96function update004(){
97        // new trinity ships are wrong saved as T1 shipes
98        if (CURRENT_DB_UPDATE < "004" )
99        {
100                $qry = new DBQuery();
101               
102                $query = "UPDATE kb3_ships
103                                        INNER JOIN kb3_ship_classes ON scl_id = shp_class
104                                        SET shp_techlevel = 2
105                                        WHERE scl_class IN ('Electronic Attack Ship','Heavy Interdictor','Black Ops','Marauder','Heavy Interdictor','Jump Freighter')
106                                        AND shp_techlevel = 1;";
107                $qry->execute($query);         
108                config::set("DBUpdate","004"); 
109        }
110}
111
112function update005(){
113        // Blueprints and small fixes
114        if (CURRENT_DB_UPDATE < "005" )
115        {
116                $qry = new DBQuery();
117$query = <<<EOF
118INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29249, 105, 'Magnate Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0);
119
120INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29267, 111, 'Apotheosis Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0);
121
122INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29338, 106, 'Omen Navy Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0);
123
124INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29339, 106, 'Scythe Fleet Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0);
125
126INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29341, 106, 'Osprey Navy Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0);
127
128INSERT INTO `kb3_invtypes` (`typeID`, `groupID`, `typeName`, `description`, `icon`, `radius`, `mass`, `volume`, `capacity`, `portionSize`, `raceID`, `basePrice`, `marketGroupID`) VALUES (29345, 106, 'Exequror Navy Issue Blueprint', '', '0', 0, 0, 0.01, 0, 1, 0, 0, 0);
129
130INSERT INTO `kb3_dgmtypeattributes` (`typeID`, `attributeID`, `value`) VALUES ('29249', '422', '1');
131
132UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='180';
133UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='181';
134
135UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='182';
136UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='183';
137UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='184';
138
139UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='228';
140UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='229';
141UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='230';
142UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='231';
143UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='232';
144
145UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='277';
146UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='278';
147UPDATE `kb3_dgmattributetypes` SET `icon` = '50_11' WHERE `attributeID`='279';
148
149UPDATE `kb3_dgmattributetypes` SET `icon` = '04_12' WHERE `attributeID`='193';
150UPDATE `kb3_dgmattributetypes` SET `icon` = '04_12' WHERE `attributeID`='235';
151
152UPDATE `kb3_dgmattributetypes` SET `icon` = '22_14' WHERE `attributeID`='108';
153UPDATE `kb3_dgmattributetypes` SET `icon` = '22_14' WHERE `attributeID`='197';
154
155UPDATE `kb3_dgmattributetypes` SET `icon` = '07_15' WHERE `attributeID`='137';
156
157UPDATE `kb3_dgmattributetypes` SET `icon` = '24_01' WHERE `attributeID`='77';
158
159UPDATE `kb3_dgmattributetypes` SET `icon` = '22_08' WHERE `attributeID`='153';
160
161UPDATE `kb3_dgmattributetypes` SET `icon` = '07_15' WHERE `attributeID`='484';
162EOF;
163
164        $qry->execute($query);
165        config::set("DBUpdate","005");
166
167        }
168}
169
170function update_slot_of_group($id,$oldSlot = 0 ,$newSlot){
171        $qry  = new DBQuery();
172        $query = "UPDATE kb3_item_types
173                                SET itt_slot = $newSlot WHERE itt_id = $id and itt_slot = $oldSlot;";
174        $qry->execute($query);
175        $query = "UPDATE kb3_items_destroyed
176                                INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID
177                                SET itd_itl_id = $newSlot
178                                WHERE itd_itl_id = $oldSlot;";
179        $qry->execute($query);
180       
181        $query = "UPDATE kb3_items_dropped
182                                INNER JOIN kb3_invtypes ON groupID = $id AND itd_itm_id = typeID
183                                SET itd_itl_id = $newSlot
184                                WHERE itd_itl_id = $oldSlot;";
185        $qry->execute($query);
186}
187
188function move_item_to_group($id,$oldGroup ,$newGroup){
189        $qry  = new DBQuery();
190        $query = "UPDATE kb3_invtypes
191                                SET groupID = $newGroup 
192                                WHERE typeID = $id AND groupID = $oldGroup;";
193        $qry->execute($query);
194}
195
196?>
Note: See TracBrowser for help on using the browser.