FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

#96 - [Feature] Signal acti for hawkeye(6yes approved) :O

 
Post new topic   Reply to topic    Drop Shock Forum Index -> Open Source
View previous topic :: View next topic  
Author Message
khaibar
Advanced


Joined: 14 Dec 2007
Posts: 1141

PostPosted: Mon Apr 29, 2013 10:27 pm    Post subject: #96 - [Feature] Signal acti for hawkeye(6yes approved) :O Reply with quote

Code don't work D:

Code:
elseif ($acti->effect == "isign") {
   if (($planet_escort == "Y") OR ($planetid == 8)){
         if ( ($relic->faction_owner == $user["i_faction"]) OR (in_array($relic->faction_owner,$faction_allies[($user["i_faction"])])) ){
            SetMessage(1, "<fa".$rel_type."><DIV CLASS='unitDivLR'>is <font class='alerttextb'>broadcasting</font> a signal from (<font class='helptext'>".$relic->x_pos."</font>,<font class='helptext'>".$relic->y_pos."</font>)" "</DIV>", $userid );
         }
         else {
            SetMessage(1, "<en".$rel_type."><DIV CLASS='unitDivLR'>is <font class='alerttextb'>broadcasting</font> a signal from (<font class='helptext'>".$relic->x_pos."</font>,<font class='helptext'>".$relic->y_pos."</font>)" "</DIV>", $userid );
         }
      }
   }


$relic doesn't exist in that code block o:
You need to pull it out of the database like so

Code:

//******************************************
//Get Relic Data, if needed
//******************************************
if (($planet_relics == "Y") OR ($planet_beacon == "Y") OR ($planet_factionwar == "Y") OR ($planet_escort == "Y")){
   $relicdata =& $db->getAll("SELECT r.faction_owner, r.x_pos, r.i_turn_captured, r.y_pos, r.is_beacon, r.is_node, r.is_hatch, r.is_super, r.i_cap_id, r.id, r.i_owner
         FROM deployed_relics r WHERE r.i_planet = ? ",
      array($planetid), DB_FETCHMODE_OBJECT);
   if (DB::isError($relicdata)) { ReportDBError($relicdata); }
}

//******************************************
//Update User Data
//******************************************
$usercount = 0;
foreach ($userdata as $userid => $user) {
   $usercount += 1;
   
   //Report Bandit Bonus
   if ($banCount[$planetid]>149) {
      $banBonus = round($banCount[$planetid]/100);
      if ($banBonus > 4) { $banBonus = 4; }
      SetMessage(0, "<b>x".$banBonus."</b> <font class='helptextb'>Bandit Bonus is Active!</font>", $userid );
   }
   
   if (($planet_relics == "Y") OR ($planet_beacon == "Y") OR ($planet_factionwar == "Y")) {

      $can_report = false;
      if ($planet_relics == "Y") { $can_report = true; }
      elseif ( ($planet_PvP_train=="Y") AND (fmod($planet_thisturn,3) == 0) ) { $can_report = true; }
      elseif ( ($planet_PvP_train=="N") AND (fmod($planet_thisturn,10) == 0) ) { $can_report = true; }

      if ( ($planet_PvP_train == "Y") AND ($planet_noSha == "Y") ) { $can_report = false; }

      if ($can_report) {
         //Report any captured Relics
         foreach ($relicdata as $relic){


But that's not healthy 8')

Try taking a different approach. Do the same query but r.i_planet = id of planet you're on and only select the variables you need.
Then do a for-each statement like this

Code:
foreach ($relicdata as $relic){
if ( ($relic->faction_owner == $user["i_faction"]) OR (in_array($relic->faction_owner,$faction_allies[($user["i_faction"])])) ){
            SetMessage(1, "<fa".$rel_type."><DIV CLASS='unitDivLR'>is <font class='alerttextb'>broadcasting</font> a signal from (<font class='helptext'>".$relic->x_pos."</font>,<font class='helptext'>".$relic->y_pos."</font>)" "</DIV>", $userid );
         }
         else {
            SetMessage(1, "<en".$rel_type."><DIV CLASS='unitDivLR'>is <font class='alerttextb'>broadcasting</font> a signal from (<font class='helptext'>".$relic->x_pos."</font>,<font class='helptext'>".$relic->y_pos."</font>)" "</DIV>", $userid );
         }


Given that this maybe called multiple times (once per acti) and even though not much relics reside in that planet it's still not optimized.

Perhaps add a new array called $ryn_relics that loads all of them once. That array would be searched when the said acti is used

Please make a thread in open source section for every thread in council section. You guys know how much I like you and I really want to be able to express that love (8
Back to top
View user's profile Send private message
Habarshi
Simple


Joined: 10 Aug 2015
Posts: 2

PostPosted: Mon Aug 10, 2015 12:58 am    Post subject: Reply with quote

It is new that I never knew before.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Drop Shock Forum Index -> Open Source All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group