Ticket #8839: array3.patch
File array3.patch, 10.3 KB (added by , 17 years ago) |
---|
-
gui/massadd.cpp
123 123 124 124 // Perform a breadth-first scan of the filesystem. 125 125 while (!_scanStack.empty() && (g_system->getMillis() - t) < kMaxScanTime) { 126 FilesystemNode dir = _scanStack.pop(); 126 FilesystemNode dir = _scanStack.top(); 127 _scanStack.pop(); 127 128 128 129 FSList files; 129 130 if (!dir.getChildren(files, FilesystemNode::kListAll)) { -
engines/sword1/animation.cpp
281 281 _textMan->releaseText(2); 282 282 free(_textSpriteBuf); 283 283 _textSpriteBuf = NULL; 284 delete _movieTexts.remove_at(0); 284 delete _movieTexts[0]; 285 _movieTexts.remove_at(0); 285 286 } 286 287 } 287 288 processFrame(); … … 310 311 } 311 312 312 313 while (!_movieTexts.empty()) { 313 delete _movieTexts.remove_at(_movieTexts.size() - 1); 314 delete _movieTexts[_movieTexts.size() - 1]; 315 _movieTexts.remove_at(_movieTexts.size() - 1); 314 316 } 315 317 316 318 while (_snd->isSoundHandleActive(_bgSoundHandle)) -
engines/agi/picture.cpp
267 267 268 268 // Exit if stack is empty 269 269 while (!stack.empty()) { 270 Common::Point p = stack. pop();270 Common::Point p = stack.top(); 271 271 unsigned int c; 272 272 int newspanUp, newspanDown; 273 273 274 stack.pop(); 275 274 276 if (!isOkFillHere(p.x, p.y)) 275 277 continue; 276 278 -
engines/agi/predictive.cpp
83 83 words.push_back(word); 84 84 while ((word = strtok(NULL, " ")) != NULL) 85 85 words.push_back(word); 86 words.insert_at(1, words.remove_at(wordnum + 1));87 86 88 Common::String tmp; 87 Common::String tmp = words[wordnum + 1]; 88 words.remove_at(wordnum + 1); 89 words.insert_at(1, tmp); 90 91 tmp = ""; 89 92 for (uint8 i = 0; i < words.size(); i++) 90 93 tmp += words[i] + " "; 91 94 tmp.deleteLastChar(); -
engines/lure/scripts.cpp
971 971 break; 972 972 973 973 case S_OPCODE_ADD: 974 stack.push(stack.pop() + stack.pop()); 974 tempVal = stack.top(); 975 stack.pop(); 976 tempVal += stack.top(); 977 stack.pop(); 978 stack.push(tempVal); 975 979 break; 976 980 977 981 case S_OPCODE_SUBTRACT: 978 v1 = stack.pop(); 979 v2 = stack.pop(); 982 v1 = stack.top(); 983 stack.pop(); 984 v2 = stack.top(); 985 stack.pop(); 980 986 stack.push(v2 - v1); 981 987 break; 982 988 983 989 case S_OPCODE_MULTIPLY: 984 tempVal = stack.pop() * stack.pop(); 990 tempVal = stack.top(); 991 stack.pop(); 992 tempVal *= stack.top(); 993 stack.pop(); 985 994 stack.push(tempVal & 0xffff); 986 995 param = (uint16) (tempVal >> 16); 987 996 break; 988 997 989 998 case S_OPCODE_DIVIDE: 990 v1 = stack.pop(); 991 v2 = stack.pop(); 999 v1 = stack.top(); 1000 stack.pop(); 1001 v2 = stack.top(); 1002 stack.pop(); 992 1003 stack.push(v2 / v1); 993 1004 param = v2 % v1; // remainder 994 1005 break; 995 1006 996 1007 case S_OPCODE_EQUALS: 997 stack.push((stack.pop() == stack.pop()) ? 1 : 0); 1008 v1 = stack.top(); 1009 stack.pop(); 1010 v2 = stack.top(); 1011 stack.pop(); 1012 stack.push((v1 == v2) ? 1 : 0); 998 1013 break; 999 1014 1000 1015 case S_OPCODE_NOT_EQUALS: 1001 stack.push((stack.pop() != stack.pop()) ? 1 : 0); 1016 v1 = stack.top(); 1017 stack.pop(); 1018 v2 = stack.top(); 1019 stack.pop(); 1020 stack.push((v1 != v2) ? 1 : 0); 1002 1021 break; 1003 1022 1004 1023 case S_OPCODE_LT: 1005 v1 = stack.pop(); 1006 v2 = stack.pop(); 1024 v1 = stack.top(); 1025 stack.pop(); 1026 v2 = stack.top(); 1027 stack.pop(); 1007 1028 stack.push(v2 < v1 ? 1 : 0); 1008 1029 break; 1009 1030 1010 1031 case S_OPCODE_GT: 1011 v1 = stack.pop(); 1012 v2 = stack.pop(); 1032 v1 = stack.top(); 1033 stack.pop(); 1034 v2 = stack.top(); 1035 stack.pop(); 1013 1036 stack.push(v2 > v1 ? 1 : 0); 1014 1037 break; 1015 1038 1016 1039 case S_OPCODE_LTE: 1017 v1 = stack.pop(); 1018 v2 = stack.pop(); 1040 v1 = stack.top(); 1041 stack.pop(); 1042 v2 = stack.top(); 1043 stack.pop(); 1019 1044 stack.push(v2 <= v1 ? 1 : 0); 1020 1045 break; 1021 1046 1022 1047 case S_OPCODE_GTE: 1023 v1 = stack.pop(); 1024 v2 = stack.pop(); 1048 v1 = stack.top(); 1049 stack.pop(); 1050 v2 = stack.top(); 1051 stack.pop(); 1025 1052 stack.push(v2 >= v1 ? 1 : 0); 1026 1053 break; 1027 1054 1028 1055 case S_OPCODE_AND: 1029 stack.push(stack.pop() & stack.pop()); 1056 v1 = stack.top(); 1057 stack.pop(); 1058 v2 = stack.top(); 1059 stack.pop(); 1060 stack.push(v1 & v2); 1030 1061 break; 1031 1062 1032 1063 case S_OPCODE_OR: 1033 stack.push(stack.pop() | stack.pop()); 1064 v1 = stack.top(); 1065 stack.pop(); 1066 v2 = stack.top(); 1067 stack.pop(); 1068 stack.push(v1 | v2); 1034 1069 break; 1035 1070 1036 1071 case S_OPCODE_LOGICAL_AND: 1037 v1 = stack.pop(); 1038 v2 = stack.pop(); 1072 v1 = stack.top(); 1073 stack.pop(); 1074 v2 = stack.top(); 1075 stack.pop(); 1039 1076 stack.push(((v1 != 0) && (v2 != 0)) ? 1 : 0); 1040 1077 break; 1041 1078 1042 1079 case S_OPCODE_LOGICAL_OR: 1043 v1 = stack.pop(); 1044 v2 = stack.pop(); 1080 v1 = stack.top(); 1081 stack.pop(); 1082 v2 = stack.top(); 1083 stack.pop(); 1045 1084 stack.push(((v1 != 0) || (v2 != 0)) ? 1 : 0); 1046 1085 break; 1047 1086 … … 1053 1092 1054 1093 case S_OPCODE_SET_FIELD: 1055 1094 fieldNum = param >> 1; 1056 v1 = stack.pop(); 1095 v1 = stack.top(); 1096 stack.pop(); 1057 1097 fields.setField(fieldNum, v1); 1058 1098 break; 1059 1099 … … 1096 1136 } 1097 1137 1098 1138 param1 = 0; param2 = 0; param3 = 0; 1099 if (!stack.empty()) param1 = stack.pop(); 1100 if (!stack.empty()) param2 = stack.pop(); 1101 if (!stack.empty()) param3 = stack.pop(); 1139 if (!stack.empty()) { 1140 param1 = stack.top(); 1141 stack.pop(); 1142 } 1143 if (!stack.empty()) { 1144 param2 = stack.top(); 1145 stack.pop(); 1146 } 1147 if (!stack.empty()) { 1148 param3 = stack.top(); 1149 stack.pop(); 1150 } 1102 1151 1103 1152 if (rec->methodIndex == 0xff) 1104 1153 warning("Undefined script method %d", param); … … 1109 1158 break; 1110 1159 1111 1160 case S_OPCODE_COND_JUMP: 1112 v1 = stack.pop(); 1161 v1 = stack.top(); 1162 stack.pop(); 1113 1163 if (v1 == 0) offset += (int16) param; 1114 1164 break; 1115 1165 … … 1123 1173 1124 1174 case S_OPCODE_END: 1125 1175 // Signal to end the execution 1126 if (!methodStack.empty()) 1127 offset = methodStack.pop(); 1128 else 1176 if (!methodStack.empty()) { 1177 offset = methodStack.top(); 1178 methodStack.pop(); 1179 } else 1129 1180 breakFlag = true; 1130 1181 break; 1131 1182 -
engines/parallaction/parallaction.cpp
606 606 void Parallaction::popParserTables() { 607 607 assert(_opcodes.size() > 0); 608 608 609 _currentOpcodes = _opcodes.pop(); 610 _currentStatements = _statements.pop(); 609 _currentOpcodes = _opcodes.top(); 610 _opcodes.pop(); 611 _currentStatements = _statements.top(); 612 _statements.pop(); 611 613 } 612 614 613 615 void Parallaction::parseStatement() { -
common/stack.h
102 102 const int s = size(); 103 103 return _stack[s - 1]; 104 104 } 105 T pop() { 106 T tmp = top(); 105 void pop() { 107 106 _stack.remove_at(size() - 1); 108 return tmp;109 107 } 110 108 int size() const { 111 109 return _stack.size(); -
common/array.h
27 27 28 28 #include "common/scummsys.h" 29 29 #include "common/algorithm.h" 30 #include "common/noncopyable.h" 30 31 31 32 namespace Common { 32 33 … … 52 53 copy(array._data, array._data + _size, _data); 53 54 } 54 55 55 ~Array() {56 delete [] _data;56 virtual ~Array() { 57 clear(); 57 58 } 58 59 59 60 void push_back(const T& element) { … … 67 68 _size += array._size; 68 69 } 69 70 70 void insert_at( int idx, const T& element) {71 assert(idx >= 0 && (uint)idx<= _size);71 void insert_at(uint idx, const T& element) { 72 assert(idx <= _size); 72 73 ensureCapacity(_size + 1); 73 74 copy_backward(_data + idx, _data + _size, _data + _size + 1); 74 75 _data[idx] = element; 75 76 _size++; 76 77 } 77 78 78 T remove_at(int idx) { 79 assert(idx >= 0 && (uint)idx < _size); 80 T tmp = _data[idx]; 79 virtual void remove_at(uint idx) { 80 assert(idx < _size); 81 81 copy(_data + idx + 1, _data + _size, _data + idx); 82 82 _size--; 83 return tmp;84 83 } 85 84 86 85 // TODO: insert, remove, ... 87 86 88 T& operator []( int idx) {89 assert(idx >= 0 && (uint)idx< _size);87 T& operator [](uint idx) { 88 assert(idx < _size); 90 89 return _data[idx]; 91 90 } 92 91 93 const T& operator []( int idx) const {94 assert(idx >= 0 && (uint)idx< _size);92 const T& operator [](uint idx) const { 93 assert(idx < _size); 95 94 return _data[idx]; 96 95 } 97 96 … … 112 111 return _size; 113 112 } 114 113 115 v oid clear() {114 virtual void clear() { 116 115 delete [] _data; 117 116 _data = 0; 118 117 _size = 0; … … 182 181 } 183 182 }; 184 183 184 template<class T> 185 class ManagedArray : public Array<T*>, public NonCopyable { 186 private: 187 typedef Array<T*> Base; 188 189 class PtrEq { 190 private: 191 const T &_key; 192 193 public: 194 PtrEq(const T &key) : _key(key) { } 195 196 bool operator ()(const T* item) { 197 assert(item); 198 return _key == *item; 199 } 200 }; 201 public: 202 typedef typename Array<T*>::iterator iterator; 203 typedef typename Array<T*>::const_iterator const_iterator; 204 typedef typename Array<T*>::value_type value_type; 205 206 virtual void remove_at(uint idx) { 207 delete Base::operator [](idx); 208 Base::remove_at(idx); 209 } 210 211 void extract(uint idx) { 212 Base::remove_at(idx); 213 } 214 215 bool contains(const T &key) { 216 return find_if(Base::begin(), Base::end(), PtrEq(key)) != Base::end(); 217 } 218 219 virtual void clear() { 220 for (iterator i = Base::begin(); i != Base::end(); i++) { 221 delete *i; 222 } 223 224 Base::clear(); 225 } 226 }; 227 185 228 } // End of namespace Common 186 229 187 230 #endif -
graphics/cursorman.cpp
72 72 if (_cursorStack.empty()) 73 73 return; 74 74 75 Cursor *cur = _cursorStack.pop(); 75 Cursor *cur = _cursorStack.top(); 76 _cursorStack.pop(); 76 77 delete cur; 77 78 78 79 if (!_cursorStack.empty()) { … … 144 145 if (_cursorPaletteStack.empty()) 145 146 return; 146 147 147 Palette *pal = _cursorPaletteStack.pop(); 148 Palette *pal = _cursorPaletteStack.top(); 149 _cursorPaletteStack.pop(); 148 150 delete pal; 149 151 150 152 if (_cursorPaletteStack.empty()) {