If somebody can explain what stupid thing I have done to make 0 > 11 = true... Please tell me! (getSectorName in scene.h)

This commit is contained in:
James Brown 2003-08-17 08:11:59 +00:00
parent 6685abb86d
commit 4d94385c2e
4 changed files with 27 additions and 12 deletions

12
README
View File

@ -20,12 +20,12 @@ Running:
Exit with 'q', and don't press f1 or the inventory... as things go a bit weird.
Notes -
Won't compile in MSVC (see TODO), but will on MingW32. However under
Windows you must put .exe in the DataDir and set it to '.' in residual.ini
Windows-style path slashing isn't parsed yet.
Seems to run in Software GL for several people - need to debug opengl
setup/usage and figure out why. See TODO for other stuff.
* Will run extremely slow on anything but fairly recent cards (due to use of
glDrawPixels). Requires OpenGL in all cases.
* Won't compile in MSVC (see TODO), but will on MingW32.
* Windows you must put .exe in the DataDir and set it to '.' in residual.ini,
Windows-style path slashing isn't parsed yet.
* See TODO for other stuff
ScummVM-Residual Team Credits:
Daniel Schepler Initial engine codebase & LUA upgrades

View File

@ -461,9 +461,10 @@ static void IsActorInSector(void) {
int i, numSectors = Engine::instance()->currScene()->getSectorCount();
warning("IsActorInSector(%s, %s): STUB", act->name(), name);
printf("Looping over %d sectors\n", numSectors);
for (i=0; i<numSectors; i++) {
if (strstr(Engine::instance()->currScene()->getSectorName(i), name)) {
const char *sector_name = Engine::instance()->currScene()->getSectorName(i);
if (sector_name && strstr(sector_name, name)) {
warning("found sector!");
if (Engine::instance()->currScene()->isPointInSector(i, act->pos())) {
lua_pushnumber(Engine::instance()->currScene()->getSectorID(i));

View File

@ -54,6 +54,7 @@ Scene::Scene(const char *name, const char *buf, int len) :
lights_[i].load(ts);
// Calculate the number of sectors
numSectors_ = -1;
ts.expectString("section: sectors");
if (ts.eof()) // Sometimes there ARE no sectors (eg, inv room)
return;
@ -71,7 +72,8 @@ Scene::~Scene() {
delete [] cmaps_;
delete [] setups_;
delete [] lights_;
delete [] sectors_; // Endy<-yaz: if I remember well, sometime sectors aren't allocated... (inventory room)
if (sectors_)
delete [] sectors_;
}
void Scene::Sector::load(TextSplitter &ts) {

18
scene.h
View File

@ -54,9 +54,21 @@ public:
// Sector access functions
int getSectorCount() { return numSectors_; }
const char *getSectorName(int id) const { return sectors_[id].name_.c_str(); }
int getSectorType(int id) { return sectors_[id].type_; }
int getSectorID(int id) { return sectors_[id].id_; }
const char *getSectorName(int id) const {
// FIXME: Will someone explain to me why my machine thinks 0 > 11?!?
if (id > numSectors_) {
return sectors_[id].name_.c_str();
} else {
printf("Sector %d > %d\n", id, numSectors_);
return NULL;
}
}
int getSectorType(int id) {
if (id > numSectors_) return sectors_[id].type_; else return -1;
}
int getSectorID(int id) {
if (id > numSectors_) return sectors_[id].id_; else return -1;
}
bool isPointInSector(int id, Vector3d point) { return false; } // FIXME: Need pointInPoly func
private: