diff options
Diffstat (limited to 'src/client/main.cpp')
| -rw-r--r-- | src/client/main.cpp | 82 |
1 files changed, 12 insertions, 70 deletions
diff --git a/src/client/main.cpp b/src/client/main.cpp index 763c9f3..13a52e4 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -46,33 +46,11 @@ void loadIrrLibs(lua_State* L, IrrlichtDevice* device){ load_physfuncs(L); } -static int GetRandInt(int TMax) { return rand() % TMax; } - void RemoveISceneNode(btRigidBody* rb){ ISceneNode *Node = static_cast<ISceneNode*>(rb->getUserPointer()); - Node->remove(); -} -/* -// Removes all objects from the world -void ClearObjects(btDiscreteDynamicsWorld* wr, core::list<btRigidBody*> objs, void(*f)(btRigidBody*)) { - - for(list<btRigidBody *>::Iterator Iterator = objs.begin(); Iterator != objs.end(); ++Iterator) { - btRigidBody *Object = *Iterator; - - if(f){ - (*f)(Object); - } - // Delete irrlicht node - ISceneNode *Node = static_cast<ISceneNode *>(Object->getUserPointer()); + if(Node) Node->remove(); - - // Remove the object from the world - wr->removeRigidBody(Object); - delete Object; - } - objs.clear(); } -*/ // Converts a quaternion to an euler angle void QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler) { @@ -92,6 +70,8 @@ void QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler) { } void UpdateElement(btRigidBody* TObject){ + + if(TObject->getUserPointer() != NULL){ //UpdateRender(*Iterator); scene::ISceneNode *Node = static_cast<scene::ISceneNode *>((TObject)->getUserPointer()); @@ -103,36 +83,12 @@ void UpdateElement(btRigidBody* TObject){ btVector3 EulerRotation; QuaternionToEuler(TObject->getOrientation(), EulerRotation); Node->setRotation(core::vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2])); -} -/* -// Runs the physics simulation. -// - TDeltaTime tells the simulation how much time has passed since the last frame so the simulation can run independently of the frame rate. Optionally pass in an argument that will be called on every rigidbody in the world -void UpdatePhysics(double TDeltaTime, void(*f)(btRigidBody*)) { - - World->stepSimulation(TDeltaTime * 0.02f, 60); - - // Relay the object's orientation to irrlicht - for(core::list<btRigidBody *>::Iterator it = Objects.begin(); it != Objects.end(); ++it) { - (*f)(*it); } } -*/ int main(int argc, char *argv[]){ printf("Brok[en]gine Client"); // Initialize bullet - /* - btBroadphaseInterface *BroadPhase = new btAxisSweep3(btVector3(-1000, -1000, -1000), btVector3(1000, 1000, 1000)); - printf("Broadphase\n"); - btDefaultCollisionConfiguration *CollisionConfiguration = new btDefaultCollisionConfiguration(); - printf("Collision config\n"); - btCollisionDispatcher *Dispatcher = new btCollisionDispatcher(CollisionConfiguration); - printf("Dispatcher\n"); - btSequentialImpulseConstraintSolver *Solver = new btSequentialImpulseConstraintSolver(); - printf("Solver\n"); - World = new btDiscreteDynamicsWorld(Dispatcher, BroadPhase, Solver, CollisionConfiguration); - printf("Physics world init ok.\n"); - */ phys_genesis(); //Create a new lua state, this gets shared everywhere @@ -151,7 +107,7 @@ int main(int argc, char *argv[]){ //Sets the global event handeler GlobalEventReceiver ger = GlobalEventReceiver(device); device->setEventReceiver(&ger); - int iErr = luaL_dofile(state,"../data/guitest.lua"); + int iErr = luaL_dofile(state,"../data/init.lua"); if(iErr != 0){ lua_error(state); printf("Failed to open lua file:../data/guitest.lua\n"); @@ -165,7 +121,6 @@ int main(int argc, char *argv[]){ IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); - ITimer* irrTimer = device->getTimer(); device->setWindowCaption(L"Bork[en]gine Client"); @@ -174,7 +129,6 @@ int main(int argc, char *argv[]){ //u32 TimeStamp = irrTimer->getTime(), DeltaTime = 0; //high_resolution_clock::time_point t1 = high_resolution_clock::now(); while(device->run()){ - gameloop_net(L); gameloop_phys(UpdateElement); if(device->isWindowActive()){ @@ -183,7 +137,6 @@ int main(int argc, char *argv[]){ //double steps = delta.count() * 100; //UpdatePhysics(steps,UpdateElement); //t1 = now; - driver->beginScene(true, true, SColor(255,100,101,140)); smgr->drawAll(); @@ -193,31 +146,20 @@ int main(int argc, char *argv[]){ }else{ device->yield(); } - lua_getglobal(state,"GAME"); - lua_getfield(state,-1,"tick"); - if(!lua_isnil(state,-1)) - lua_call(state,0,0); - lua_pop(state,2); + lua_getglobal(state,"GAME");//{} + lua_getfield(state,-1,"tick");//{},function_tick() + if(!lua_isnil(state,-1)){ + lua_call(state,0,0); + lua_pop(state,1); + }else{ + lua_pop(state,2); + } } printf("Closeing lua state...\n"); //lua_close(state); //printf("clearing objects...\n"); //ClearObjects(World,Objects,RemoveISceneNode); //Clearing objects must be done after we droped the device. phys_shutdown(RemoveISceneNode); - /* - printf("cleared objects\n"); - delete BroadPhase; - printf("deleted broadphase\n"); - delete CollisionConfiguration; - printf("deleted collision config\n"); - delete Dispatcher; - printf("Deleted dispatcher\n"); - delete Solver; - printf("deleted solver\n"); - - delete World; //Muah ha ha - printf("deleted world\n"); - */ device->drop(); printf("droped device\n"); |
