aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMax Horn2009-05-03 22:45:13 +0000
committerMax Horn2009-05-03 22:45:13 +0000
commitf108a31ad71404f115de776366dae985dd8e4f48 (patch)
tree2b61533413daf0fb252b9cbddf0d5c272d1f1b07 /engines/sci
parentc7a5a17acfa1353c221be8c09576503b395c29ef (diff)
downloadscummvm-rg350-f108a31ad71404f115de776366dae985dd8e4f48.tar.gz
scummvm-rg350-f108a31ad71404f115de776366dae985dd8e4f48.tar.bz2
scummvm-rg350-f108a31ad71404f115de776366dae985dd8e4f48.zip
SCI: Made SegManager::heap_size unsigned
svn-id: r40290
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/gc.cpp6
-rw-r--r--engines/sci/engine/savegame.cpp14
-rw-r--r--engines/sci/engine/scriptconsole.cpp2
-rw-r--r--engines/sci/engine/scriptdebug.cpp8
-rw-r--r--engines/sci/engine/seg_manager.cpp16
-rw-r--r--engines/sci/engine/seg_manager.h8
6 files changed, 24 insertions, 30 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp
index abdcd9f26f..474d3fbc5a 100644
--- a/engines/sci/engine/gc.cpp
+++ b/engines/sci/engine/gc.cpp
@@ -78,7 +78,7 @@ reg_t_hash_map *find_all_used_references(EngineState *s) {
Common::Array<SegInterface *> interfaces;
reg_t_hash_map *normal_map = NULL;
WorklistManager wm;
- int i;
+ uint i;
interfaces.resize(sm->heap_size);
for (i = 1; i < sm->heap_size; i++)
@@ -105,7 +105,7 @@ reg_t_hash_map *find_all_used_references(EngineState *s) {
#endif
// Init: Execution Stack
- for (i = 0; i <= s->execution_stack_pos; i++) {
+ for (i = 0; (int)i <= s->execution_stack_pos; i++) {
ExecStack &es = s->_executionStack[i];
if (es.type != EXEC_STACK_TYPE_KERNEL) {
@@ -191,7 +191,7 @@ void free_unless_used(void *refcon, reg_t addr) {
}
void run_gc(EngineState *s) {
- int seg_nr;
+ uint seg_nr;
deallocator_t deallocator;
SegManager *sm = s->seg_manager;
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 710c6b8a20..e4f0269843 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -172,8 +172,8 @@ void Menubar::saveLoadWithSerializer(Common::Serializer &s) {
}
void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
- int allocated_heap_size = heap_size;
- s.syncAsSint32LE(heap_size);
+ uint allocated_heap_size = heap_size;
+ s.syncAsUint32LE(heap_size);
s.syncAsSint32LE(reserved_id);
s.syncAsSint32LE(exports_wide);
s.syncAsSint32LE(gc_mark_bits);
@@ -184,7 +184,7 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
assert(heap);
if (allocated_heap_size != heap_size)
heap = (MemObject**)sci_realloc((void *)heap, heap_size * sizeof(MemObject *));
- for (int i = 0; i < heap_size; ++i)
+ for (uint i = 0; i < heap_size; ++i)
sync_MemObjPtr(s, heap[i]);
s.syncAsSint32LE(Clones_seg_id);
@@ -538,9 +538,7 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename
// FIXME: This should probably be turned into a SegManager method
static SegmentId find_unique_seg_by_type(SegManager *self, int type) {
- int i;
-
- for (i = 0; i < self->heap_size; i++)
+ for (uint i = 0; i < self->heap_size; i++)
if (self->heap[i] &&
self->heap[i]->getType() == type)
return i;
@@ -614,7 +612,7 @@ static void load_script(EngineState *s, SegmentId seg) {
// FIXME: The following should likely become a SegManager method
static void reconstruct_scripts(EngineState *s, SegManager *self) {
- int i;
+ uint i;
MemObject *mobj;
for (i = 0; i < self->heap_size; i++) {
if (self->heap[i]) {
@@ -694,7 +692,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) {
// FIXME: The following should likely become a SegManager method
static void reconstruct_clones(EngineState *s, SegManager *self) {
- int i;
+ uint i;
MemObject *mobj;
for (i = 0; i < self->heap_size; i++) {
diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp
index b3e334cda9..b7d95fd063 100644
--- a/engines/sci/engine/scriptconsole.cpp
+++ b/engines/sci/engine/scriptconsole.cpp
@@ -281,7 +281,7 @@ int parse_reg_t(EngineState *s, const char *str, reg_t *dest) { // Returns 0 on
const char *str_objname;
char *str_suffix;
char suffchar = 0;
- int i;
+ uint i;
// Parse obj by name
tmp = (char *)strchr(str, '+');
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 07d65a6d99..d8cb4b4246 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -283,7 +283,7 @@ int c_sfx_01_track(EngineState *s) {
const char *(*_debug_get_input)(void) = _debug_get_input_default;
int c_segtable(EngineState *s) {
- int i;
+ uint i;
sciprintf(" ---- segment table ----\n");
for (i = 0; i < s->seg_manager->heap_size; i++) {
@@ -668,12 +668,12 @@ static int c_mousepos(EngineState *s) {
}
int c_seginfo(EngineState *s) {
- unsigned int i = 0;
+ uint i = 0;
if (cmd_paramlength) {
while (i < cmd_paramlength) {
int nr = cmd_params[i++].val;
- if (nr < 0 || nr >= s->seg_manager->heap_size || !s->seg_manager->heap[nr]) {
+ if (nr < 0 || (uint)nr >= s->seg_manager->heap_size || !s->seg_manager->heap[nr]) {
sciprintf("Segment %04x does not exist\n", nr);
return 1;
}
@@ -681,7 +681,7 @@ int c_seginfo(EngineState *s) {
_c_single_seg_info(s, s->seg_manager->heap[nr]);
}
} else
- for (i = 0; i < (unsigned int)s->seg_manager->heap_size; i++) {
+ for (i = 0; i < s->seg_manager->heap_size; i++) {
if (s->seg_manager->heap[i]) {
sciprintf("[%04x] ", i);
_c_single_seg_info(s, s->seg_manager->heap[i]);
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index e6899d6920..fff7a72b4e 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -75,8 +75,6 @@ MemObject *SegManager::allocNonscriptSegment(memObjType type, SegmentId *segid)
}
SegManager::SegManager(bool sci1_1) {
- int i;
-
// Initialise memory count
mem_allocated = 0;
@@ -97,7 +95,7 @@ SegManager::SegManager(bool sci1_1) {
isSci1_1 = sci1_1;
// initialize the heap pointers
- for (i = 0; i < heap_size; i++) {
+ for (uint i = 0; i < heap_size; i++) {
heap[i] = NULL;
}
@@ -107,10 +105,8 @@ SegManager::SegManager(bool sci1_1) {
// Destroy the object, free the memorys if allocated before
SegManager::~SegManager() {
- int i;
-
// Free memory
- for (i = 0; i < heap_size; i++) {
+ for (uint i = 0; i < heap_size; i++) {
if (heap[i])
deallocate(i, false);
}
@@ -347,11 +343,11 @@ MemObject *SegManager::memObjAllocate(SegmentId segid, int hash_id, memObjType t
return NULL;
}
- if (segid >= heap_size) {
+ if (segid >= (int)heap_size) {
void *temp;
int oldhs = heap_size;
- if (segid >= heap_size * 2) {
+ if (segid >= (int)heap_size * 2) {
sciprintf("SegManager: hash_map error or others??");
return NULL;
}
@@ -443,7 +439,7 @@ int SegManager::segGet(int script_id) const {
Script *SegManager::getScript(const int id, idFlag flag) {
const int seg = (flag == SCRIPT_ID) ? segGet(id) : id;
- if (seg < 0 || seg >= heap_size) {
+ if (seg < 0 || (uint)seg >= heap_size) {
error("SegManager::getScript(%d,%d): seg id %x out of bounds", id, flag, seg);
}
if (!heap[seg]) {
@@ -460,7 +456,7 @@ Script *SegManager::getScript(const int id, idFlag flag) {
// false - invalid seg
// true - valid seg
bool SegManager::check(int seg) {
- if (seg < 0 || seg >= heap_size) {
+ if (seg < 0 || (uint)seg >= heap_size) {
return false;
}
if (!heap[seg]) {
diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h
index 5477c0b2a4..45971ae96d 100644
--- a/engines/sci/engine/seg_manager.h
+++ b/engines/sci/engine/seg_manager.h
@@ -38,13 +38,13 @@ enum idFlag {
SEG_ID
};
-#define GET_SEGMENT(mgr, index, rtype) (((index) > 0 && (mgr).heap_size > index) ? \
+#define GET_SEGMENT(mgr, index, rtype) (((index) > 0 && (int)(mgr).heap_size > index) ? \
(((mgr).heap[index] && (mgr).heap[index]->getType() == rtype)? (mgr).heap[index] : NULL) : NULL)
-#define GET_SEGMENT_ANY(mgr, index) (((index) > 0 && (mgr).heap_size > index) ? \
+#define GET_SEGMENT_ANY(mgr, index) (((index) > 0 && (int)(mgr).heap_size > index) ? \
(((mgr).heap[index])? (mgr).heap[index] : NULL) : NULL)
-#define GET_OBJECT_SEGMENT(mgr, index) (((index) > 0 && (mgr).heap_size > index) ? \
+#define GET_OBJECT_SEGMENT(mgr, index) (((index) > 0 && (int)(mgr).heap_size > index) ? \
(((mgr).heap[index] && ((mgr).heap[index]->getType() == MEM_OBJ_SCRIPT || (mgr).heap[index]->getType() == MEM_OBJ_CLONES))? (mgr).heap[index] \
: NULL): NULL)
@@ -389,7 +389,7 @@ private:
IntMapper *id_seg_map; // id - script id; seg - index of heap
public: // TODO: make private
MemObject **heap;
- int heap_size; // size of the heap
+ uint heap_size; // size of the heap
int reserved_id;
int exports_wide;
bool isSci1_1;