A few random incomplete sector thingies. still have to add a cvsignore for grimdialog :P

This commit is contained in:
James Brown 2003-08-16 06:41:37 +00:00
parent a86ece994c
commit bdd79593e9
3 changed files with 62 additions and 4 deletions

41
lua.cpp
View File

@ -428,6 +428,43 @@ static void IsMessageGoing() {
}
}
// Sector functions
static void GetActorSector(void) {
Actor *act = check_actor(1);
int sectorType = check_int(2);
warning("GetActorSector(%s, %d): STUB", act->name(), sectorType);
if (0) {
lua_pushnumber(0); // id
lua_pushstring(""); // name
lua_pushnumber(0); // type
} else {
lua_pushnil();
}
}
static void IsActorInSector(void) {
Actor *act = check_actor(1);
const char *name = luaL_check_string(2);
int i, numSectors = Engine::instance()->currScene()->getSectorCount();
warning("IsActorInSector(%s, %s): STUB", act->name(), name);
for (i=0; i<numSectors; i++) {
if (strstr(Engine::instance()->currScene()->getSectorName(i), name)) {
warning("found sector!");
if (Engine::instance()->currScene()->isPointInSector(i, act->pos())) {
lua_pushnumber(Engine::instance()->currScene()->getSectorID(i));
lua_pushstring((char*)Engine::instance()->currScene()->getSectorName(i));
lua_pushnumber(Engine::instance()->currScene()->getSectorType(i));
}
}
}
lua_pushnil();
}
// Scene functions
static void MakeCurrentSet() {
@ -723,8 +760,6 @@ static char *stubFuncs[] = {
"GetActorRot",
"GetPointSector",
"IsPointInSector",
"GetActorSector",
"IsActorInSector",
"SetActorFrustrumCull",
"ShutUpActor",
"SetActorFollowBoxes",
@ -979,6 +1014,8 @@ struct luaL_reg builtins[] = {
{ "GetVisibleThings", GetVisibleThings },
{ "SayLine", SayLine },
{ "IsMessageGoing", IsMessageGoing },
{ "GetActorSector", GetActorSector },
{ "IsActorInSector", IsActorInSector },
{ "MakeCurrentSet", MakeCurrentSet },
{ "MakeCurrentSetup", MakeCurrentSetup },
{ "GetCurrentSetup", GetCurrentSetup },

View File

@ -90,7 +90,21 @@ void Scene::Sector::load0(TextSplitter &ts, char *name, int id) {
name_ = name;
id_ = id;
ts.scanString(" type %256s", 1, buf);
type_ = buf;
// FIXME: I don't think these are right (see grim loc_4A7D19, result is var_200?)
if (strstr(buf, "walk"))
type_ = 1;
else if (strstr(buf, "funnel"))
type_ = 3; // ??
else if (strstr(buf, "camera"))
type_ = 2;
else if (strstr(buf, "special"))
type_ = 4;
else if (strstr(buf, "chernobyl"))
type_ = 0;
else
error("Unknown sector type '%s' in room setup", buf);
ts.scanString(" default visibility %256s", 1, buf);
visibility_ = buf;
ts.scanString(" height %f", 1, &height_);

View File

@ -52,6 +52,13 @@ public:
void setSetup(int num) { currSetup_ = setups_ + num; }
int setup() const { return currSetup_ - setups_; }
// 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_; }
bool isPointInSector(int id, Vector3d point) { return false; } // FIXME: Need pointInPoly func
private:
struct Setup { // Camera setup data
void load(TextSplitter &ts);
@ -76,7 +83,7 @@ private:
void load0(TextSplitter &ts, char *name, int id);
int numVertices_, id_;
std::string name_;
std::string type_;
int type_;
std::string visibility_;
Vector3d *vertices_;
float height_;