[Scummvm-cvs-logs] CVS: residual walkplane.cpp,NONE,1.1 walkplane.h,NONE,1.1 Makefile,1.2,1.3 lua.cpp,1.6,1.7 scene.cpp,1.8,1.9 scene.h,1.6,1.7

James Brown ender at users.sourceforge.net
Tue Aug 19 00:21:02 CEST 2003


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1:/tmp/cvs-serv6232

Modified Files:
	Makefile lua.cpp scene.cpp scene.h 
Added Files:
	walkplane.cpp walkplane.h 
Log Message:
Move walkplane/sector code to seperate file


--- NEW FILE: walkplane.cpp ---

// Residual - Virtual machine to run LucasArts' 3D adventure games
// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

#include "walkplane.h"
#include "textsplit.h"

void Sector::load(TextSplitter &ts) {
  char buf[256];
  int id = 0;
  ts.scanString(" sector %256s", 1, buf);
  ts.scanString(" id %d", 1, &id);
  load0(ts, buf, id);
}

void Sector::load0(TextSplitter &ts, char *name, int id) {
  char buf[256];
  int i = 0;
  float height = 12345.f; // Yaz: this is in the original code...
  Vector3d tempVert;

  name_ = name;
  id_ = id;
  ts.scanString(" type %256s", 1, buf);

  // Flags used in function at 4A66C0 (buildWalkPlane)

  if (strstr(buf, "walk"))
   type_ = 0x1000;

  else if (strstr(buf, "funnel"))
   type_ = 0x1100;
  else if (strstr(buf, "camera"))
   type_ = 0x2000;
  else if (strstr(buf, "special"))
   type_ = 0x4000;
  else if (strstr(buf, "chernobyl"))
   type_ = 0x8000;
  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_);
  ts.scanString(" numvertices %d", 1, &numVertices_);
  vertices_ = new Vector3d[numVertices_];

  ts.scanString(" vertices: %f %f %f", 3, &vertices_[0].x(), &vertices_[0].y(),
&vertices_[0].z());
  for (i=1;i<numVertices_;i++)
    ts.scanString(" %f %f %f", 3, &vertices_[i].x(), &vertices_[i].y(), &vertices_[i].z());
}



--- NEW FILE: walkplane.h ---
// Residual - Virtual machine to run LucasArts' 3D adventure games
// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

#ifndef WALKPLANE_H
#define WALKPLANE_H

#include "vector3d.h"
#include "debug.h"
#include <SDL.h>
#include <SDL_opengl.h>
#include <string>

class TextSplitter;

class Sector { 
public:
    void load(TextSplitter &ts);
    void load0(TextSplitter &ts, char *name, int id);

    const char *name() const { return name_.c_str(); }
    const int id() const { return id_; }
    const int type() const { return 0; } // FIXME: Implement type de-masking
    bool isPointInSector(Vector3d point) const { 
     // FIXME: Implement point-in-poly function
     return false; 
    } 

private:
    int numVertices_, id_;

    std::string name_;
    int type_;
    std::string visibility_;
    Vector3d *vertices_;
    float height_;
};
#endif

Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/residual/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile	17 Aug 2003 04:22:18 -0000	1.2
+++ Makefile	19 Aug 2003 07:20:03 -0000	1.3
@@ -5,7 +5,8 @@
 
 OBJS = main.o lab.o bitmap.o model.o resource.o material.o debug.o \
 	textsplit.o lua.o registry.o localize.o scene.o engine.o actor.o \
-	sound.o mixer.o keyframe.o costume.o
+	sound.o mixer.o keyframe.o costume.o walkplane.o
+
 DEPS = $(OBJS:.o=.d)
 
 residual: $(OBJS) lua/lib/liblua.a lua/lib/liblualib.a

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- lua.cpp	17 Aug 2003 08:30:18 -0000	1.6
+++ lua.cpp	19 Aug 2003 07:20:03 -0000	1.7
@@ -462,13 +462,14 @@
 
   warning("IsActorInSector(%s, %s): SEMI-STUB", act->name(), name);
   for (i=0; i<numSectors; i++) {
-   const char *sector_name = Engine::instance()->currScene()->getSectorName(i);
-   if (sector_name && strstr(sector_name, name)) {
+   Sector *sector = Engine::instance()->currScene()->getSectorBase(i);
+
+   if (strstr(sector->name(), 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));
+    if (sector->isPointInSector(act->pos())) {
+      lua_pushnumber(sector->id());
+      lua_pushstring((char*)sector->name());
+      lua_pushnumber(sector->type());
     }
    }
   } 

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- scene.cpp	18 Aug 2003 14:38:33 -0000	1.8
+++ scene.cpp	19 Aug 2003 07:20:03 -0000	1.9
@@ -84,52 +84,6 @@
    delete [] sectors_; 
 }
 
-void Scene::Sector::load(TextSplitter &ts) {
-  char buf[256];
-  int id = 0;
-  ts.scanString(" sector %256s", 1, buf);
-  ts.scanString(" id %d", 1, &id);
-  load0(ts, buf, id);
-}
-
-void Scene::Sector::load0(TextSplitter &ts, char *name, int id) {
-  char buf[256];
-  int i = 0;
-  float height = 12345.f; // Yaz: this is in the original code...
-  Vector3d tempVert;
-
-  name_ = name;
-  id_ = id;
-  ts.scanString(" type %256s", 1, buf);
-
-  // FIXME: I don't think these are right (see grim loc_4A7D19, result is var_200?)
-  // Yaz: actualy, those should be flags that are later used function at 4A66C0 (I named it buildWalkPlane)
-
-  
-  if (strstr(buf, "walk"))
-   type_ = 0x1000;
-  else if (strstr(buf, "funnel"))
-   type_ = 0x1100; 
-  else if (strstr(buf, "camera"))
-   type_ = 0x2000;
-  else if (strstr(buf, "special"))
-   type_ = 0x4000;
-  else if (strstr(buf, "chernobyl"))
-   type_ = 0x8000;
-  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_);
-  ts.scanString(" numvertices %d", 1, &numVertices_);
-  vertices_ = new Vector3d[numVertices_];
-
-  ts.scanString(" vertices: %f %f %f", 3, &vertices_[0].x(), &vertices_[0].y(), &vertices_[0].z());
-  for (i=1;i<numVertices_;i++)
-    ts.scanString(" %f %f %f", 3, &vertices_[i].x(), &vertices_[i].y(), &vertices_[i].z());
-}
-
 void Scene::Setup::load(TextSplitter &ts) {
   char buf[256];
 

Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- scene.h	18 Aug 2003 14:25:21 -0000	1.6
+++ scene.h	19 Aug 2003 07:20:03 -0000	1.7
@@ -22,6 +22,7 @@
 #include "bitmap.h"
 #include "color.h"
 #include "debug.h"
+#include "walkplane.h"
 #include <SDL.h>
 #include <SDL_opengl.h>
 #include <string>
@@ -56,14 +57,13 @@
   int setup() const { return currSetup_ - setups_; }
 
   // Sector access functions
-  #define validSector(id) ((numSectors_ >= 0) && (id < numSectors_))
   int getSectorCount() { return numSectors_; }
-  const char *getSectorName(int id) const {
-   if (validSector(id)) return sectors_[id].name_.c_str(); else return NULL;
+  Sector *getSectorBase(int id) { 
+   if ((numSectors_ >= 0) && (id < numSectors_))
+    return &sectors_[id];
+   else
+    return NULL;
   }
-  int getSectorType(int id) { if (validSector(id)) return sectors_[id].type_; else return -1; }
-  int getSectorID(int id) { if (validSector(id)) return sectors_[id].id_; else return -1; }
-  bool isPointInSector(int id, Vector3d point) { return false; } // FIXME: Need pointInPoly func
 
 private:
   struct Setup {		// Camera setup data
@@ -82,17 +82,6 @@
     Vector3d pos_, dir_;
     Color color_;
     float intensity_, umbraangle_, penumbraangle_;
-  };
-
-  struct Sector {		// Walkarea 'sectors'
-    void load(TextSplitter &ts);
-    void load0(TextSplitter &ts, char *name, int id);
-    int numVertices_, id_;
-    std::string name_;
-    int type_;
-    std::string visibility_;
-    Vector3d *vertices_;
-    float height_;
   };
 
   std::string name_;





More information about the Scummvm-git-logs mailing list