mail[Wesnoth-commits] r13995 - /trunk/src/game_events.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by queen . killer on October 17, 2006 - 16:32:
Author: queenkiller
Date: Tue Oct 17 16:31:40 2006
New Revision: 13995

URL: http://svn.gna.org/viewcvs/wesnoth?rev=13995&view=rev
Log:
fix bug #7473 - random range only in positive number

Modified:
    trunk/src/game_events.cpp

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=13995&r1=13994&r2=13995&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Tue Oct 17 16:31:40 2006
@@ -896,9 +896,9 @@
                if(random.empty() == false) {
                        std::string random_value, word;
                        std::vector<std::string> words;
-                       std::vector<std::pair<size_t,size_t> > ranges;
+                       std::vector<std::pair<long,long> > ranges;
                        int num_choices = 0;
-                       std::string::size_type pos = 0, pos2 = 
std::string::npos, tmp;
+                       std::string::size_type pos = 0, pos2 = 
std::string::npos;
                        std::stringstream 
ss(std::stringstream::in|std::stringstream::out);
                        while (pos2 != random.length()) {
                                pos = pos2+1;
@@ -909,7 +909,7 @@
 
                                word = random.substr(pos, pos2-pos);
                                words.push_back(word);
-                               tmp = word.find("..");
+                               std::string::size_type tmp = word.find("..");
 
 
                                if (tmp == std::string::npos) {
@@ -923,7 +923,7 @@
                                        const std::string second = 
word.substr(tmp+2,
                                                        random.length());
 
-                                       size_t low, high;
+                                       long low, high;
                                        ss << first + " " + second;
                                        ss >> low;
                                        ss >> high;
@@ -934,13 +934,13 @@
                                                low = high;
                                                high = tmp;
                                        }
-                                       ranges.push_back(std::pair<int, 
int>(low,high));
+                                       ranges.push_back(std::pair<long, 
long>(low,high));
                                        num_choices += (high - low) + 1;
                                }
                        }
 
                        size_t choice = get_random() % num_choices;
-                       tmp = 0;
+                       long tmp = 0;
                        for(size_t i = 0; i < ranges.size(); i++) {
                                tmp += (ranges[i].second - ranges[i].first) + 
1;
                                if (tmp > choice) {




Related Messages


Powered by MHonArc, Updated Tue Oct 17 16:41:08 2006