wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src unit_types.cpp unit_types.hpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src unit_types.cpp unit_types.hpp
Date: Mon, 21 Feb 2005 19:03:53 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/02/22 00:03:53

Modified files:
        src            : unit_types.cpp unit_types.hpp 

Log message:
        Applied InvPhi's patch (#3760) to cache unit alignment computations. 
Presumably speeds up the AI, at a small memory expense.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_types.cpp.diff?tr1=1.81&tr2=1.82&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_types.hpp.diff?tr1=1.59&tr2=1.60&r1=text&r2=text

Patches:
Index: wesnoth/src/unit_types.cpp
diff -u wesnoth/src/unit_types.cpp:1.81 wesnoth/src/unit_types.cpp:1.82
--- wesnoth/src/unit_types.cpp:1.81     Mon Feb 21 09:05:51 2005
+++ wesnoth/src/unit_types.cpp  Tue Feb 22 00:03:53 2005
@@ -1,4 +1,4 @@
-/* $Id: unit_types.cpp,v 1.81 2005/02/21 09:05:51 silene Exp $ */
+/* $Id: unit_types.cpp,v 1.82 2005/02/22 00:03:53 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -528,7 +528,7 @@
       leadership_(o.leadership_), illuminates_(o.illuminates_),
       skirmish_(o.skirmish_), teleport_(o.teleport_),
       nightvision_(o.nightvision_), steadfast_(o.steadfast_),
-      can_advance_(o.can_advance_),
+      can_advance_(o.can_advance_), alignment_(o.alignment_),
       movementType_(o.movementType_), possibleTraits_(o.possibleTraits_),
       genders_(o.genders_), defensive_animations_(o.defensive_animations_),
       teleport_animations_(o.teleport_animations_)
@@ -610,6 +610,18 @@
        teleport_ = has_ability("teleport");
        nightvision_ = has_ability("night vision");
        steadfast_ = has_ability("steadfast");
+       
+       const std::string& align = cfg_["alignment"];
+       if(align == "lawful")
+               alignment_ = LAWFUL;
+       else if(align == "chaotic")
+               alignment_ = CHAOTIC;
+       else if(align == "neutral")
+               alignment_ = NEUTRAL;
+       else {
+               lg::err(lg::config) << "Invalid alignment found for " << name() 
<< ": '" << align << "'\n";
+               alignment_ = NEUTRAL;
+       }
 
        const std::string& alpha_blend = cfg_["alpha"];
        if(alpha_blend.empty() == false) {
@@ -882,17 +894,7 @@
 
 unit_type::ALIGNMENT unit_type::alignment() const
 {
-       const std::string& align = cfg_["alignment"];
-       if(align == "lawful")
-               return LAWFUL;
-       else if(align == "chaotic")
-               return CHAOTIC;
-       else if(align == "neutral")
-               return NEUTRAL;
-       else {
-               lg::err(lg::config) << "Invalid alignment found for " << name() 
<< ": '" << align << "'\n";
-               return NEUTRAL;
-       }
+       return alignment_;
 }
 
 const char* unit_type::alignment_description(unit_type::ALIGNMENT align)
Index: wesnoth/src/unit_types.hpp
diff -u wesnoth/src/unit_types.hpp:1.59 wesnoth/src/unit_types.hpp:1.60
--- wesnoth/src/unit_types.hpp:1.59     Sat Feb 19 09:26:31 2005
+++ wesnoth/src/unit_types.hpp  Tue Feb 22 00:03:53 2005
@@ -1,4 +1,4 @@
-/* $Id: unit_types.hpp,v 1.59 2005/02/19 09:26:31 isaaccp Exp $ */
+/* $Id: unit_types.hpp,v 1.60 2005/02/22 00:03:53 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -273,6 +273,7 @@
        bool nightvision_;
        bool steadfast_;
        bool can_advance_;
+       ALIGNMENT alignment_;
 
        unit_movement_type movementType_;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]