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_display.cpp unit.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src unit_display.cpp unit.cpp
Date: Sat, 18 Sep 2004 06:13:27 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/09/18 10:06:58

Modified files:
        src            : unit_display.cpp unit.cpp 

Log message:
        Small cleanup: references are not pointers, no need to have convoluted 
code.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_display.cpp.diff?tr1=1.30&tr2=1.31&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.cpp.diff?tr1=1.95&tr2=1.96&r1=text&r2=text

Patches:
Index: wesnoth/src/unit.cpp
diff -u wesnoth/src/unit.cpp:1.95 wesnoth/src/unit.cpp:1.96
--- wesnoth/src/unit.cpp:1.95   Sun Aug 29 20:33:01 2004
+++ wesnoth/src/unit.cpp        Sat Sep 18 10:06:57 2004
@@ -1,4 +1,4 @@
-/* $Id: unit.cpp,v 1.95 2004/08/29 20:33:01 Sirp Exp $ */
+/* $Id: unit.cpp,v 1.96 2004/09/18 10:06:57 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -845,27 +845,20 @@
                case STATE_DEFENDING_SHORT: {
                        const attack_type::RANGE range = (state_ == 
STATE_DEFENDING_LONG) ? attack_type::LONG_RANGE : attack_type::SHORT_RANGE;
                        const unit_animation* const anim = 
type_->defend_animation(getsHit_,range);
-                       if(anim != NULL) {
-                               const unit_animation::frame& anim_frame = 
anim->get_current_frame();
-                               const std::string* img = &anim_frame.image;
-                               if(img != NULL) {
-                                       return *img;
-                               }
-                       }
-
-                       return type_->image_defensive(range);
+                       if (anim != NULL)
+                               return anim->get_current_frame().image;
+                       else
+                               return type_->image_defensive(range);
                }
                case STATE_ATTACKING: {
                        if(attackType_ == NULL)
                                return type_->image();
 
-                       const unit_animation::frame& anim_frame = 
attackType_->animation().get_current_frame();
-                       const std::string* const img = &anim_frame.image;
-
-                       if(img->empty())
+                       const std::string& img = 
attackType_->animation().get_current_frame().image;
+                       if (img.empty())
                                return 
type_->image_fighting(attackType_->range());
                        else
-                               return *img;
+                               return img;
                }
                case STATE_HEALING:
                        return type_->image_healing();
Index: wesnoth/src/unit_display.cpp
diff -u wesnoth/src/unit_display.cpp:1.30 wesnoth/src/unit_display.cpp:1.31
--- wesnoth/src/unit_display.cpp:1.30   Sun Sep 12 12:33:08 2004
+++ wesnoth/src/unit_display.cpp        Sat Sep 18 10:06:57 2004
@@ -716,7 +716,7 @@
                const unit_animation::frame& unit_frame = 
attack_anim.get_current_frame(unit_animation::UNIT_FRAME);
                int new_halo_x = unit_frame.halo_x;
                int new_halo_y = unit_frame.halo_y;
-               const std::string* unit_image = &unit_frame.image;
+               const std::string& unit_image = unit_frame.image.empty() ? 
attacker.image() : unit_frame.image;
 
                if(!attacker.facing_left()) {
                        xoffset *= -1;
@@ -727,11 +727,7 @@
 
                xoffset = int(double(xoffset)*disp.zoom());
 
-               if(unit_image->empty()) {
-                       unit_image = &attacker.image();
-               }
-
-               surface image((unit_image == NULL) ? surface(NULL) : 
image::get_image(*unit_image));
+               surface image(image::get_image(unit_image));
                if(attacker.facing_left() == false) {
                        image.assign(image::reverse_image(image));
                }




reply via email to

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