Strict mode: Changed several warnings due to logic bugs into errors. If an error pops up from these ones, please add the game where it occurred and the steps to reproduce the error before turning it into a warning

svn-id: r49973
This commit is contained in:
Filippos Karapetis 2010-06-17 23:50:28 +00:00
parent 9c1ec81d76
commit db70d66e4a
12 changed files with 42 additions and 34 deletions

View File

@ -640,7 +640,7 @@ int Kernel::findRegType(reg_t reg) {
return 0; // Invalid
if (!mobj->isValidOffset(reg.offset))
warning("[KERN] ref %04x:%04x is invalid", PRINT_REG(reg));
error("[KERN] ref %04x:%04x is invalid", PRINT_REG(reg));
switch (mobj->getType()) {
case SEG_TYPE_SCRIPT:

View File

@ -373,14 +373,14 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) {
s->r_acc = SIGNAL_REG;
if (!s->_segMan->isHeapObject(avoider)) {
warning("DoAvoider() where avoider %04x:%04x is not an object", PRINT_REG(avoider));
error("DoAvoider() where avoider %04x:%04x is not an object", PRINT_REG(avoider));
return NULL_REG;
}
client = readSelector(segMan, avoider, SELECTOR(client));
if (!s->_segMan->isHeapObject(client)) {
warning("DoAvoider() where client %04x:%04x is not an object", PRINT_REG(client));
error("DoAvoider() where client %04x:%04x is not an object", PRINT_REG(client));
return NULL_REG;
}
@ -389,7 +389,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) {
if (!s->_segMan->isHeapObject(mover)) {
if (mover.segment) {
warning("DoAvoider() where mover %04x:%04x is not an object", PRINT_REG(mover));
error("DoAvoider() where mover %04x:%04x is not an object", PRINT_REG(mover));
}
return s->r_acc;
}
@ -450,7 +450,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) {
angle -= 360;
}
warning("DoAvoider failed for avoider %04x:%04x", PRINT_REG(avoider));
error("DoAvoider failed for avoider %04x:%04x", PRINT_REG(avoider));
} else {
int heading = readSelectorValue(segMan, client, SELECTOR(heading));

View File

@ -776,8 +776,8 @@ void SegManager::reconstructScripts(EngineState *s) {
if (getSciVersion() < SCI_VERSION_1_1) {
if (!obj->initBaseObject(this, addr, false)) {
warning("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr));
scr->scriptObjRemove(addr);
error("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr));
//scr->scriptObjRemove(addr);
}
}
}
@ -809,7 +809,7 @@ void SegManager::reconstructClones() {
const Object *baseObj = getObject(seeker.getSpeciesSelector());
seeker.cloneFromObject(baseObj);
if (!baseObj)
warning("Clone entry without a base class: %d", j);
error("Clone entry without a base class: %d", j);
} // end for
} // end if
} // end for

View File

@ -277,8 +277,8 @@ void script_instantiate_sci0(Script *scr, int segmentId, SegManager *segMan) {
obj->initSpecies(segMan, addr);
if (!obj->initBaseObject(segMan, addr)) {
warning("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr));
scr->scriptObjRemove(addr);
error("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr));
//scr->scriptObjRemove(addr);
}
}
break;

View File

@ -221,7 +221,7 @@ void Script::load(ResourceManager *resMan) {
_localsOffset = 0;
if (_localsOffset + _localsCount * 2 + 1 >= (int)_bufSize) {
warning("Locals extend beyond end of script: offset %04x, count %d vs size %d", _localsOffset, _localsCount, _bufSize);
error("Locals extend beyond end of script: offset %04x, count %d vs size %d", _localsOffset, _localsCount, _bufSize);
_localsCount = (_bufSize - _localsOffset) >> 1;
}
} else {
@ -268,12 +268,14 @@ Object *Script::scriptObjInit(reg_t obj_pos, bool fullObjectInit) {
return obj;
}
#if 0
void Script::scriptObjRemove(reg_t obj_pos) {
if (getSciVersion() < SCI_VERSION_1_1)
obj_pos.offset += 8;
_objects.erase(obj_pos.toUint16());
}
#endif
// This helper function is used by Script::relocateLocal and Object::relocate
static bool relocateBlock(Common::Array<reg_t> &block, int block_location, SegmentId segment, int location, size_t scriptSize) {
@ -288,7 +290,7 @@ static bool relocateBlock(Common::Array<reg_t> &block, int block_location, Segme
return false;
if (rel & 1) {
warning("Attempt to relocate odd variable #%d.5e (relative to %04x)\n", idx, block_location);
error("Attempt to relocate odd variable #%d.5e (relative to %04x)\n", idx, block_location);
return false;
}
block[idx].segment = segment; // Perform relocation
@ -372,7 +374,7 @@ uint16 Script::validateExportFunc(int pubfunct) {
bool exportsAreWide = (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE);
if (_numExports <= pubfunct) {
warning("validateExportFunc(): pubfunct is invalid");
error("validateExportFunc(): pubfunct is invalid");
return 0;
}
@ -464,7 +466,7 @@ SegmentRef LocalVariables::dereference(reg_t pointer) {
if (ret.maxSize > 0) {
ret.reg = &_locals[pointer.offset / 2];
} else {
warning("LocalVariables::dereference: Offset at end or out of bounds %04x:%04x", PRINT_REG(pointer));
error("LocalVariables::dereference: Offset at end or out of bounds %04x:%04x", PRINT_REG(pointer));
ret.reg = 0;
}
return ret;
@ -551,7 +553,7 @@ void Script::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback not
for (uint i = 0; i < obj->getVarCount(); i++)
(*note)(param, obj->getVariable(i));
} else {
warning("Request for outgoing script-object reference at %04x:%04x failed", PRINT_REG(addr));
error("Request for outgoing script-object reference at %04x:%04x failed", PRINT_REG(addr));
}
} else {
/* warning("Unexpected request for outgoing script-object references at %04x:%04x", PRINT_REG(addr));*/
@ -642,7 +644,7 @@ void ListTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) {
void ListTable::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback note) const {
if (!isValidEntry(addr.offset)) {
warning("Invalid list referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
error("Invalid list referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
return;
}
@ -662,7 +664,7 @@ void NodeTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) {
void NodeTable::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback note) const {
if (!isValidEntry(addr.offset)) {
warning("Invalid node referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
error("Invalid node referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
return;
}
const Node *node = &(_table[addr.offset]);
@ -736,7 +738,7 @@ int Object::propertyOffsetToId(SegManager *segMan, int propertyOffset) const {
int selectors = getVarCount();
if (propertyOffset < 0 || (propertyOffset >> 1) >= selectors) {
warning("Applied propertyOffsetToId to invalid property offset %x (property #%d not in [0..%d])",
error("Applied propertyOffsetToId to invalid property offset %x (property #%d not in [0..%d])",
propertyOffset, propertyOffset >> 1, selectors - 1);
return -1;
}
@ -814,7 +816,7 @@ void ArrayTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) {
void ArrayTable::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback note) const {
if (!isValidEntry(addr.offset)) {
warning("Invalid array referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
error("Invalid array referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
return;
}

View File

@ -406,11 +406,13 @@ public:
*/
Object *scriptObjInit(reg_t obj_pos, bool fullObjectInit = true);
#if 0
/**
* Removes a script object
* @param obj_pos Location (segment, offset) of the object.
*/
void scriptObjRemove(reg_t obj_pos);
#endif
/**
* Processes a relocation block witin a script

View File

@ -188,13 +188,13 @@ void writeSelector(SegManager *segMan, reg_t object, Selector selectorId, reg_t
ObjVarRef address;
if ((selectorId < 0) || (selectorId > (int)g_sci->getKernel()->getSelectorNamesSize())) {
warning("Attempt to write to invalid selector %d of"
error("Attempt to write to invalid selector %d of"
" object at %04x:%04x.", selectorId, PRINT_REG(object));
return;
}
if (lookupSelector(segMan, object, selectorId, &address, NULL) != kSelectorVariable)
warning("Selector '%s' of object at %04x:%04x could not be"
error("Selector '%s' of object at %04x:%04x could not be"
" written to", g_sci->getKernel()->getSelectorName(selectorId).c_str(), PRINT_REG(object));
else
*address.getPointer(segMan) = value;
@ -217,7 +217,7 @@ void invokeSelector(EngineState *s, reg_t object, int selectorId,
g_sci->getKernel()->getSelectorName(selectorId).c_str(), PRINT_REG(object));
}
if (slc_type == kSelectorVariable) {
warning("Attempting to invoke variable selector %s of object %04x:%04x",
error("Attempting to invoke variable selector %s of object %04x:%04x",
g_sci->getKernel()->getSelectorName(selectorId).c_str(), PRINT_REG(object));
}

View File

@ -207,7 +207,7 @@ Common::String SciEngine::getSciLanguageString(const char *str, kLanguage lang,
// Copy double-byte character
char c2 = *(++seeker);
if (!c2) {
warning("SJIS character %02X is missing second byte", c);
error("SJIS character %02X is missing second byte", c);
break;
}
fullWidth += c;

View File

@ -128,7 +128,8 @@ static StackPtr validate_stack_addr(EngineState *s, StackPtr sp) {
static int validate_arithmetic(reg_t reg) {
if (reg.segment) {
warning("[VM] Attempt to read arithmetic value from non-zero segment [%04x]", reg.segment);
// The results of this are likely unpredictable...
error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]", reg.segment);
return 0;
}
@ -137,7 +138,8 @@ static int validate_arithmetic(reg_t reg) {
static int signed_validate_arithmetic(reg_t reg) {
if (reg.segment) {
warning("[VM] Attempt to read arithmetic value from non-zero segment [%04x]", reg.segment);
// The results of this are likely unpredictable...
error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]", reg.segment);
return 0;
}
@ -159,8 +161,8 @@ static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, in
if (type == VAR_PARAM || type == VAR_TEMP) {
int total_offset = r - stack_base;
if (total_offset < 0 || total_offset >= VM_STACK_SIZE) {
warning("%s", txt.c_str());
warning("[VM] Access would be outside even of the stack (%d); access denied", total_offset);
// Fatal, as the game is trying to do an OOB access
error("%s. [VM] Access would be outside even of the stack (%d); access denied", txt.c_str(), total_offset);
return false;
} else {
debugC(2, kDebugLevelVM, "%s", txt.c_str());
@ -298,7 +300,7 @@ static void _exec_varselectors(EngineState *s) {
ExecStack &xs = s->_executionStack.back();
reg_t *var = xs.getVarPointer(s->_segMan);
if (!var) {
warning("Invalid varselector exec stack entry");
error("Invalid varselector exec stack entry");
} else {
// varselector access?
if (xs.argc) { // write?
@ -419,7 +421,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
reg_t oldReg = *varp.getPointer(s->_segMan);
reg_t newReg = argp[1];
const char *selectorName = g_sci->getKernel()->getSelectorName(selector).c_str();
warning("send_selector(): argc = %d while modifying variable selector "
error("send_selector(): argc = %d while modifying variable selector "
"%x (%s) of object %04x:%04x (%s) from %04x:%04x to %04x:%04x",
argc, selector, selectorName, PRINT_REG(send_obj),
objectName, PRINT_REG(oldReg), PRINT_REG(newReg));
@ -762,6 +764,7 @@ void run_vm(EngineState *s, bool restoring) {
scr = s->_segMan->getScriptIfLoaded(s->xs->addr.pc.segment);
if (!scr) {
// No script? Implicit return via fake instruction buffer
// FIXME: Why does this happen? Are there leftover calls in the call stack?
warning("Running on non-existant script in segment %x", s->xs->addr.pc.segment);
code_buf = _fake_return_buffer;
#ifndef DISABLE_VALIDATIONS
@ -779,6 +782,7 @@ void run_vm(EngineState *s, bool restoring) {
#endif
local_script = s->_segMan->getScriptIfLoaded(s->xs->local_segment);
if (!local_script) {
// FIXME: Why does this happen? Is the script not loaded yet at this point?
warning("Could not find local script from segment %x", s->xs->local_segment);
local_script = NULL;
s->variablesBase[VAR_LOCAL] = s->variables[VAR_LOCAL] = NULL;
@ -1661,7 +1665,7 @@ void run_vm(EngineState *s, bool restoring) {
//#ifndef DISABLE_VALIDATIONS
if (s->xs != &(s->_executionStack.back())) {
warning("xs is stale (%p vs %p); last command was %02x",
error("xs is stale (%p vs %p); last command was %02x",
(void *)s->xs, (void *)&(s->_executionStack.back()),
opcode);
}

View File

@ -216,7 +216,7 @@ Window *GfxPorts::newWindow(const Common::Rect &dims, const Common::Rect *restor
Common::Rect r;
if (!pwnd) {
warning("Can't open window!");
error("Can't open window!");
return 0;
}

View File

@ -703,7 +703,7 @@ void MidiDriver_AdLib::setVelocityReg(int regOffset, int velocity, int kbScaleLe
void MidiDriver_AdLib::setPatch(int voice, int patch) {
if ((patch < 0) || ((uint)patch >= _patches.size())) {
warning("ADLIB: Invalid patch %i requested", patch);
error("ADLIB: Invalid patch %i requested", patch);
patch = 0;
}
@ -749,7 +749,7 @@ void MidiDriver_AdLib::playSwitch(bool play) {
bool MidiDriver_AdLib::loadResource(const byte *data, uint size) {
if ((size != 1344) && (size != 2690) && (size != 5382)) {
warning("ADLIB: Unsupported patch format (%i bytes)", size);
error("ADLIB: Unsupported patch format (%i bytes)", size);
return false;
}

View File

@ -455,7 +455,7 @@ void SciMusic::sendMidiCommand(MusicEntry *pSnd, uint32 cmd) {
if (pSnd->pMidiParser)
pSnd->pMidiParser->sendToDriver(cmd);
else
warning("tried to cmdSendMidi on non midi slot (%04x:%04x)", PRINT_REG(pSnd->soundObj));
error("tried to cmdSendMidi on non midi slot (%04x:%04x)", PRINT_REG(pSnd->soundObj));
}
void SciMusic::printPlayList(Console *con) {