13. Construction Overview (buildings.php)
Starting from this article, the focus on the Xnova is on the process, which is actually a lot of functions; the structure of the page will not be explained carefully.
buildings.php documents not only deal with the construction of metal minerals, but includes construction, research, shipyards, defense four functions; by passing different parameters to decide which function to enter, so this file is actually a navigation file. Here's a brief explanation of this file.
Update the building queues of the current planet, more complex Updateplanetbatimentqueuelist ($planetrow, $user);
Handletechnologiebuild ($planetrow, $user) dealing with the current user's technology research;
Below are the parameters to enter the different function page/Shipyard page case ' fleet ': Fleetbuildingpage ($planetrow, $user);
Research page case ' study ': Researchbuildingpage ($planetrow, $user, $IsWorking [' onwork '], $IsWorking [' Workon ']);
Defense page case ' defense ': Defensesbuildingpage ($planetrow, $user);
The remaining nature is the Architectural page default:batimentbuildingpage ($planetrow, $user); Now let's look at the building of the current planet. Function Updateplanetbatimentqueuelist (& $CurrentPlanet, & $CurrentUser) {$RetValue = False
; Determine if there is a building queue, field b_building_id save building Queue if ($CurrentPlanet [' b_building_id ']!= 0) {//Enter loop, start processing queue while ($CurrentPlanet [' B _building_id ']!= 0 {//////////////////////////////////////////////////////
{//update the resources of the planet below, and then parse the Planetresourceupdate ($CurrentUser, $CurrentPlanet, $CurrentPlanet [' b_building '], false); Dispose of the current building and empty the current construction field; The code is quite simple $IsDone = ChecKplanetbuildingqueue ($CurrentPlanet, $CurrentUser);
If the previous processing succeeds, the next building in the queue will be processed, including deducting the resource if ($IsDone = = True) {setnextqueueelementontop ($CurrentPlanet, $CurrentUser);
} else {$RetValue = true;
Break
}} return $RetValue;
}
We go on, tracking into the Checkplanetbuildingqueue function, this function code is very much, in fact, simple; I do not write a comment, the next process. First, the type of the building, the construction or demolition, the time of the construction, and so on, are updated from the field b_building_id, and then the grade, upgrade or demotion of the building is updated, the maximum space and space of the planet are renewed, the time of the current building is updated to 0 and the current remaining construction It's not difficult, hehe.
It is also not difficult to follow the next building in the queue to track the Setnextqueueelementontop function. First, the construction data are parsed from the queue, then the building is judged, and the construction resources can be calculated, if it is not possible to send messages, etc. As simple as the process above, take it.