void NosuchGraphics::background(int b) { DEBUGPRINT(("NosuchGraphics::background!")); }
void TPropertyEditorMultiChoice::SetProperty(TProperty *AProperty,int32 AnIndex,BHandler *AHandler) { DEBUGPRINT("TPropertyEditorMultiChoice::SetProperty Inside."); FView->SetProperty(AProperty,AnIndex,AHandler); DEBUGPRINT("TPropertyEditorMultiChoice::SetProperty Quitting."); }
void PhysicsComponent::onEvent(Event* e) { EventType type = e->getType(); switch(type) { case EVENT_ATTRIBUTE_UPDATED: //Removes physics objects when the corresponding physics attribute is removed { Event_AttributeUpdated* attributeUpdated = static_cast<Event_AttributeUpdated*>(e); int attributeIndex = attributeUpdated->index; if(attributeUpdated->attributeEnum == ATTRIBUTE_PHYSICS) { if(attributeUpdated->isDeleted) { if(attributeIndex < physicsObjects_->size() && physicsObjects_->at(attributeIndex) != nullptr) { dynamicsWorld_->removeRigidBody(physicsObjects_->at(attributeIndex)); delete physicsObjects_->at(attributeIndex); physicsObjects_->at(attributeIndex) = nullptr; } else { DEBUGPRINT("Mismatch when synchronizing deletion of physics objects with physics attributes"); } } else if(attributeUpdated->isCreated) { } else { itrPhysics.at(attributeIndex)->reloadDataIntoBulletPhysics = true; } } /*else if(attributeUpdated->attributeEnum == ATTRIBUTE_CAMERA) { if(attributeUpdated->isDeleted) { dynamicsWorld_->removeRigidBody(frustumPhysicsObjects_->at(attributeIndex)); delete frustumPhysicsObjects_->at(attributeIndex); frustumPhysicsObjects_->at(attributeIndex) = nullptr; } }*/ break; } case EVENT_MODIFY_PHYSICS_OBJECT: { Event_ModifyPhysicsObject* modifyPhysicsObject = static_cast<Event_ModifyPhysicsObject*>(e); int physicsAttributeIndex = modifyPhysicsObject->ptr_physics.index(); if(physicsAttributeIndex < physicsObjects_->size() && physicsAttributeIndex > -1) { PhysicsObject* physicsObject = physicsObjects_->at(physicsAttributeIndex); if(physicsObject != NULL) { //Cast void pointer sent in Event_ModifyPhysicsObject to its expected data type and modify physics object accordingly switch(modifyPhysicsObject->modifyWhatDataInPhysicsObjectData) { case XKILL_Enums::ModifyPhysicsObjectData::GRAVITY: { Float3* gravity = static_cast<Float3*>(modifyPhysicsObject->data); physicsObject->setGravity(btVector3(gravity->x, gravity->y, gravity->z)); break; } case XKILL_Enums::ModifyPhysicsObjectData::VELOCITY: { Float3* velocity = static_cast<Float3*>(modifyPhysicsObject->data); physicsObject->setLinearVelocity(btVector3(velocity->x, velocity->y, velocity->z)); break; } case XKILL_Enums::ModifyPhysicsObjectData::VELOCITYPERCENTAGE: { Float3* velocityPercentage = static_cast<Float3*>(modifyPhysicsObject->data); btVector3 currentLinearVelocity = physicsObject->getLinearVelocity(); physicsObject->setLinearVelocity(btVector3(currentLinearVelocity.x()*velocityPercentage->x, currentLinearVelocity.y()*velocityPercentage->y, currentLinearVelocity.z()*velocityPercentage->z)); break; } case XKILL_Enums::ModifyPhysicsObjectData::FLAG_STATIC: { bool* staticPhysicsObject = static_cast<bool*>(modifyPhysicsObject->data); if(*staticPhysicsObject == true) { physicsObject->setCollisionFlags(physicsObject->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT); } else if(*staticPhysicsObject == false) { physicsObject->setCollisionFlags(physicsObject->getCollisionFlags() & ~ btCollisionObject::CF_STATIC_OBJECT); } break; } case XKILL_Enums::ModifyPhysicsObjectData::COLLISIONFILTERMASK: { /*In order to modify "collisionFilterMask", a physics objects needs to be removed from the Bullet Physics dynamics world and then readded using "addRigidBody", where "collisionFilterMask" is passed as argument. Write physics object data to physics attribute, modify "collisionFilterMask", and set the "reloadDataIntoBulletPhysics" flag, and this class will handle the removal and addition of the physics object.*/ short* collisionFilterMaskFromEvent = static_cast<short*>(modifyPhysicsObject->data); AttributePtr<Attribute_Physics> ptr_physics = itrPhysics.at(physicsAttributeIndex); physicsObject->writeNonSynchronizedPhysicsObjectDataToPhysicsAttribute(); ptr_physics->collisionFilterMask = *collisionFilterMaskFromEvent; ptr_physics->reloadDataIntoBulletPhysics = true; } break; case XKILL_Enums::ModifyPhysicsObjectData::GIVE_IMPULSE: { Float3* impulseVector = static_cast<Float3*>(modifyPhysicsObject->data); btVector3 impulse = convert(*impulseVector); physicsObject->applyCentralImpulse(impulse); break; } case XKILL_Enums::ModifyPhysicsObjectData::IF_TRUE_RECALCULATE_LOCAL_INERTIA_ELSE_SET_TO_ZERO: { bool* recalculateLocalInertia = static_cast<bool*>(modifyPhysicsObject->data); btVector3 localInertia = btVector3(0.0f, 0.0f, 0.0f); btScalar mass = itrPhysics.at(physicsAttributeIndex)->mass; if(*recalculateLocalInertia == true) { btCollisionShape* collisionShape = physicsObject->getCollisionShape(); collisionShape->calculateLocalInertia(mass, localInertia); physicsObject->setMassProps(mass, localInertia); physicsObject->updateInertiaTensor(); } else { physicsObject->setMassProps(mass, localInertia); } break; } } } else { ERROR_MESSAGEBOX("Invalid physics attribute id when handling event of type EVENT_MODIFY_PHYSICS_OBJECT, error 1"); } } else { ERROR_MESSAGEBOX("Invalid physics attribute id when handling event of type EVENT_MODIFY_PHYSICS_OBJECT, error 2"); } break; } case EVENT_CLOSEST_HIT_RAY_CAST: { Event_ClosestHitRayCast* event_ClosestRayCast = static_cast<Event_ClosestHitRayCast*>(e); handleEvent_ClosestRayCast(event_ClosestRayCast); break; } case EVENT_ALL_HITS_RAY_CAST: { Event_AllHitsRayCast* event_AllHitsRayCast = static_cast<Event_AllHitsRayCast*>(e); handleEvent_AllHitsRayCast(event_AllHitsRayCast); break; } case EVENT_LOAD_LEVEL_BULLET: CollisionShapes::Instance()->loadCollisionShapes(); break; case EVENT_UNLOAD_LEVEL: CollisionShapes::Instance()->unloadCollisionShapes(); break; case EVENT_NULL_PROCESS_STOPPED_EXECUTING: { //Reset apart-fallen world while(itrPhysics.hasNext()) { AttributePtr<Attribute_Physics> ptr_physics = itrPhysics.getNext(); if(ptr_physics->collisionFilterGroup == XKILL_Enums::PhysicsAttributeType::PROP) { if(physicsObjects_->at(ptr_physics.index()) != nullptr) { PropPhysicsObject* propPhysicsObject = static_cast<PropPhysicsObject*>(physicsObjects_->at(ptr_physics.index())); ptr_physics->collisionFilterGroup = XKILL_Enums::PhysicsAttributeType::WORLD; ptr_physics->collisionFilterMask = XKILL_Enums::PhysicsAttributeType::PLAYER | XKILL_Enums::PhysicsAttributeType::PROJECTILE | XKILL_Enums::PhysicsAttributeType::FRUSTUM | XKILL_Enums::PhysicsAttributeType::PICKUPABLE | XKILL_Enums::PhysicsAttributeType::RAY | XKILL_Enums::PhysicsAttributeType::PROP; ptr_physics->ptr_spatial->ptr_position->position = Float3(propPhysicsObject->worldOrigin_.x(),propPhysicsObject->worldOrigin_.y(),propPhysicsObject->worldOrigin_.z()); propPhysicsObject->setCollisionFlags(propPhysicsObject->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);//check, might not be needed ptr_physics->gravity = Float3(0.0f, 0.0f, 0.0f); ptr_physics->linearVelocity = Float3(0.0f, 0.0f, 0.0f); ptr_physics->mass = 0; ptr_physics->collisionResponse = true; SEND_EVENT(&Event_ReloadPhysicsAttributeDataIntoBulletPhysics(ptr_physics.index())); } } } break; } case EVENT_RELOAD_PHYSICS_ATTRIBUTE_DATA_INTO_BULLET_PHYSICS: { Event_ReloadPhysicsAttributeDataIntoBulletPhysics* event_ReloadPhysicsAttributeDataIntoBulletPhysics = static_cast<Event_ReloadPhysicsAttributeDataIntoBulletPhysics*>(e); int physicsAttributeId = event_ReloadPhysicsAttributeDataIntoBulletPhysics->physicsAttributeId; AttributePtr<Attribute_Physics> ptr_physics = itrPhysics.at(physicsAttributeId); ptr_physics->reloadDataIntoBulletPhysics = true; synchronizeWithAttributes(ptr_physics, physicsAttributeId); break; } } }
extern "C" void DebugMsgNKFMSignal(int a) { __NK_ASSERT_DEBUG(TheScheduler.iCurrentThread->iHeldFastMutex==(NFastMutex*)a); __KTRACE_OPT(KNKERN,DEBUGPRINT("NKFMSignal %M",a)); }
extern "C" void DebugMsgNKFMWaitYield(int a) { __KTRACE_OPT(KNKERN,DEBUGPRINT("NKFMWait: YieldTo %T",a)); }
extern "C" void __DebugMsgResched(int a) { __KTRACE_OPT(KSCHED,DEBUGPRINT("Reschedule->%T",a)); }
extern "C" void __DebugMsgBlockedFM(int a) { NFastMutex* pM=(NFastMutex*)a; __KTRACE_OPT(KSCHED2,DEBUGPRINT("Resched inter->%T, Blocked on %M",pM->iHoldingThread,pM)); }
DWORD FFGLPluginDef::InitPluginLibrary() { DWORD rval = FF_FAIL; if (m_mainfunc==NULL) { DEBUGPRINT(("HEY! m_mainfunc is NULL in InitPluginLibrary!?")); return rval; } //initialize the plugin rval = m_mainfunc(FF_INITIALISE,0,0).ivalue; if (rval!=FF_SUCCESS) return rval; //get the parameter names m_numparams = (int)m_mainfunc(FF_GETNUMPARAMETERS, 0, 0).ivalue; m_paramdefs = new FFGLParameterDef[m_numparams]; // DEBUGPRINT(("----- MALLOC new FFGLParameterDef")); int n; for (n=0; n<m_numparams; n++) { plugMainUnion u = m_mainfunc(FF_GETPARAMETERNAME,(DWORD)n,0); if (u.ivalue!=FF_FAIL && u.svalue!=NULL) { //create a temporary copy as a cstring w/null termination char newParamName[32]; const char *c = u.svalue; char *t = newParamName; //FreeFrame spec defines parameter names to be 16 characters long MAX int numChars = 0; while (*c && numChars<16) { *t = *c; t++; c++; numChars++; } //make sure there's a null at the end *t = 0; FFGLParameterDef* p; p = SetParameterName(n, newParamName); u = m_mainfunc(FF_GETPARAMETERTYPE,(DWORD)n,0); p->type = u.ivalue; u = m_mainfunc(FF_GETPARAMETERDEFAULT,(DWORD)n,0); if ( p->type != FF_TYPE_TEXT ) { p->default_float_val = u.fvalue; DEBUGPRINT1(("Float Parameter n=%d s=%s type=%d default=%lf\n", n,p->name.c_str(),p->type,p->default_float_val)); } else { p->default_string_val = CopyFFString16(u.svalue); DEBUGPRINT1(("String Parameter n=%d s=%s",n,p->name.c_str())); } p->num = n; } else { SetParameterName(n, "Untitled"); } } return FF_SUCCESS; }
/// \brief Main program function /// /// This function does very little on its own. It manages some output to /// player's console, directs subsystems to initialize themselves and makes /// choice of rendering engine. Then it runs the main game loop, processing /// events and sending them further into the game. int main(int argc, char *argv[]) { #if !defined(WIN32) && !defined(__APPLE__) #ifdef _GLIBCXX_DEBUG /*#if __WORDSIZE != 64*/ /* Install our signal handler */ struct sigaction sa; sa.sa_sigaction = /*(void *)*/crashhndl; sigemptyset (&sa.sa_mask); sa.sa_flags = SA_RESTART | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGFPE, &sa, NULL); /*#endif*/ #endif #endif #ifdef WIN32 WORD wVersionRequested; WSADATA wsaData; wVersionRequested = MAKEWORD( 2, 2 ); if(WSAStartup(wVersionRequested, &wsaData) != 0){ DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Winsock startup failed!!"); return -1; } if((LOBYTE(wsaData.wVersion) != 2) || (HIBYTE(wsaData.wVersion) != 2)){ WSACleanup( ); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "No Winsock 2.2 found!"); return -1; } #endif //setenv("SDL_VIDEODRIVER", "aalib", 0); //setenv("AAOPTS","-width 200 -height 70 -dim -reverse -bold -normal -boldfont -eight -extended ",0); //setenv("AAFont","-*-fixed-bold-*-*-*-*-55-*-*-*-*-*-*",0); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, PRODUCTLONG "\n"); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "================================\n"); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "version " PRODUCTVERSION "\n"); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "compiled on " __DATE__ " " __TIME__ "\n"); #ifdef BUILDVERSION DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "build %s\n", BUILDVERSION); #endif DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, " This is free software: you are free to change and redistribute it.\n" " There is NO WARRANTY, to the extent permitted by law. \n" " Review LICENSE in " PRODUCTSHORT " distribution for details.\n"); yatc_fopen_init(argv[0]); options.Load(); MAXFPS = options.maxfps; #if HAVE_LIBINTL_H // set up i18n stuff if(options.lang.size()) { std::string l("LANG="); l+=options.lang; putenv((char*)l.c_str()); std::string l2("LANGUAGE="); l2+=options.lang; putenv((char*)l2.c_str()); } // Set default locale, e.g. from environment. void * locale_result = setlocale(LC_ALL, ""); if (locale_result == NULL) { DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Failed to set locale to default."); } // Numbers should use default locale, always, to avoid sscanf() and similar problems. setlocale(LC_NUMERIC, "C"); // Determine translation path. On Bazel builds, it's in runfiles. #if !BAZEL_BUILD std::string translations_path("./translations"); #else std::string translations_path(yatc_path_to_binary() + "yatc.runfiles/yatc/translations"); #endif DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Binding path for text domain 'yatc' to %s...\n", translations_path.c_str()); // Text domain 'yatc' will be found at this path. bindtextdomain("yatc", translations_path.c_str()); // Activate text domain 'yatc'. textdomain("yatc"); // Convert text in this domain to windows-1252 (encoding of the font in pic file). bind_textdomain_codeset("yatc", "windows-1252"); #endif DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Checking graphics files existence...\n"); checkFiles(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "All graphics files were found.\n"); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Initializing windowing...\n"); if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0){ std::stringstream out; out << "Couldn't initialize SDL: " << SDL_GetError() << std::endl; DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, out.str().c_str()); NativeGUIError(out.str().c_str(), PRODUCTSHORT " Fatal Error"); exit(1); } // We are no longer dependant on .dat for this! // ivucica asks: nate, not dependant for what? why is this removed? // because of .ico? disagree. DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Loading data...\n"); if(!Objects::getInstance()->loadDat("Tibia.dat")){ DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, gettext("Loading data file failed!")); std::string forreplace = gettext("Loading the data file '$$FILENAME$$' has failed.\nPlease place '$$FILENAME$$' in the same folder as $$PRODUCTSHORT$$.\n"); forreplace = str_replace("$$FILENAME$$", "Tibia.dat", forreplace); forreplace = str_replace("$$PRODUCTSHORT$$", PRODUCTSHORT, forreplace); NativeGUIError(forreplace.c_str(), str_replace("$$PRODUCTSHORT$$", PRODUCTSHORT, gettext("$$PRODUCTSHORT$$ Fatal Error")).c_str()); exit(1); } setIcon(); // must be called prior to first call to SDL_SetVideoMode() (currently done in engine) SDL_EnableKeyRepeat(200, 50); SDL_EnableUNICODE(1); try{ g_engine = NULL; // set to null, in case anything that happens inside engine constructor wants to know we're just constructing switch(options.engine){ #ifdef USE_OPENGL case ENGINE_OPENGL: g_engine = new EngineGL; break; #endif default: DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_WARNING, "Unknown engine was selected. Falling back to SDL."); options.engine = ENGINE_SDL; case ENGINE_SDL: g_engine = new EngineSDL; break; } if(!g_engine->isSupported()){ DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_WARNING, "The selected graphics engine is not supported. Falling back to SDL."); delete g_engine; g_engine = NULL; // set to null, in case anything that happens inside engine constructor wants to know we're just constructing options.engine = ENGINE_SDL; g_engine = new EngineSDL; } // NOTE (nfries88): Make sure the window is sized as per the options int w = MAX(options.w, 656); int h = MAX(options.h, 352+options.consoleh); g_engine->doResize(w, h); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Loading skin...\n"); g_skin.loadSkin(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Skin has been loaded\n"); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Constructing gamemode...\n"); resetDefaultCursor(); if (argc == 1) { g_game = new GM_MainMenu(); //g_game = new GM_Debug(); // ivucica: this is for testing -- choice should be a cmd line option } else { g_game = new GM_MainMenu(); ProtocolGame* protocol = ProtocolConfig::createGameProtocol(854,"","","",false); g_connection = new ConnectionReplay(argv[1], protocol); if (argc==3) { sscanf(argv[2], "%f", &g_replayspeed); } } DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Initializing framerate manager...\n"); SDL_initFramerate(&g_fpsmgr); SDL_setFramerate(&g_fpsmgr,MAXFPS); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Running\n"); g_running = true; #ifdef WIN32 SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); #endif SDL_Event event; while(g_running){ //g_engine->fpsMutexLock(); //int beginticks = SDL_GetTicks(); g_engine->performFpsCalc(); //first process sdl events while(SDL_PollEvent(&event)){ switch (event.type){ case SDL_VIDEORESIZE: g_engine->doResize(event.resize.w, event.resize.h); g_game->doResize(event.resize.w, event.resize.h); break; case SDL_QUIT: g_game->onExitAttempt(); break; case SDL_KEYDOWN: onKeyDown(event); break; case SDL_KEYUP: if((event.key.keysym.sym == SDLK_LSUPER) || (event.key.keysym.sym == SDLK_RSUPER)) superkey_state = false; break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: #ifdef WINCE if (ptrx < 5 && ptry < 5) SDL_WM_IconifyWindow(); // appears to crash the application?! ah nevermind #endif g_game->mouseEvent(event); break; case SDL_MOUSEMOTION: ptrx = event.motion.x; ptry = event.motion.y; g_game->mouseEvent(event); break; default: break; } } //update current frame time g_frameDiff = SDL_GetTicks() - g_frameTime; g_frameTime = SDL_GetTicks(); if (MAXFPS) { SDL_framerateDelay(&g_fpsmgr); } //check connection if(g_connection){ g_connection->executeNetwork(); } if (!(SDL_GetAppState() & SDL_APPACTIVE)) {// if the application is minimized #ifdef WIN32 Sleep(100); // sleep a while, and don't paint #else usleep(100 * 1000); #endif } else { //otherwise update scene g_game->updateScene(); g_engine->Flip(); } g_frames ++; //g_engine->fpsMutexUnlock(); } } catch(std::string errtext){ DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, "%s", errtext.c_str()); } DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Game over\n"); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Terminating protocol connection from main...\n"); delete g_connection; g_connection = NULL; DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying map...\n"); Map::getInstance().clear(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying creature cache...\n"); Creatures::getInstance().clear(); Creatures::destroyInstance(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying inventory...\n"); Inventory::getInstance().clear(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Unloading data...\n"); Objects::getInstance()->unloadDat(); Objects::destroyInstance(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Unloading skin...\n"); g_skin.unloadSkin(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Saving options...\n"); options.Save(); DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Finishing engine...\n"); delete g_engine; DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Ending game...\n"); delete g_game; DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Shutting down SDL...\n"); SDL_Quit(); #ifdef WIN32 WSACleanup(); #endif DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Thanks for playing!\n"); return 0; }
void LEF_CliExec(void) { DEBUGPRINT("Exec\n"); printCommands(Cmds); cliLock=0; printf(CLI_PROMPT); }
FFGLPluginDef::~FFGLPluginDef() { if (m_mainfunc!=NULL) { DEBUGPRINT(("FFGLPluginDef deleted with m_mainfunc != NULL?")); } }
int ControllerParser::handler(std::vector<std::string> commands, void *args) { Network::ControllerClient * l_cntlClient = (Network::ControllerClient *) args; DEBUGPRINT("Entering handlers\n"); if (!commands.empty()) // grid parser { std::string command = commands.at(0); if ( command == "GRID" && commands.size() >= 3) { const char * ipAddr = commands.at(1).c_str(); const char * port = commands.at(2).c_str(); printf("PARSED: Grid: IP=%s PORT=%s\n", ipAddr, port); if (l_cntlClient->initGrid(ipAddr, port) < 0) return -1; return (ipAddr != NULL && port != NULL)?0:-1; } if ( command == "CLOCK" && commands.size() >= 3) { const char * ipAddr = commands.at(1).c_str(); const char * port = commands.at(2).c_str(); printf("PARSED: Clock: IP=%s PORT=%s\n", ipAddr, port); if (l_cntlClient->initClock(ipAddr, port) < 0) return -1; return (ipAddr != NULL && port != NULL)?0:-1; } if ( command == "HOME_RADIUS" && commands.size() >= 2) { float radius = atof(commands.at(1).c_str()); printf("PARSED: Home radius: %f\n", radius); l_cntlClient->setHomeRadius(radius); return true; } if ( command == "WORLD_SIZE" && commands.size() >= 2) { float worldSize = atof(commands.at(1).c_str()); printf("PARSED: World size: %f\n", worldSize); l_cntlClient->setWorldSize(worldSize); return true; } if ( command == "NUM_GRIDS" && commands.size() >= 2) { int gridSize = atoi(commands.at(1).c_str()); printf("PARSED: Number of grids: %i\n", gridSize); l_cntlClient->numGrids(gridSize); return true; } if ( command == "PUCK_TOTAL" && commands.size() >= 2) { int pucks = atoi(commands.at(1).c_str()); printf("PARSED: Number of pucks: %i\n", pucks); l_cntlClient->numPucksTotal(pucks); return true; } if (command == "#") { DEBUGPRINT("Skipped Comment\n"); return 0; } printf("WARNING: command %s not found or malformed\n", command.c_str()); return 0; } return -1; }
static void lookup_callback (void *arg, struct nfs_client *client, LOOKUP3res *result) { LOOKUP3resok *resok = &result->LOOKUP3res_u.resok; err_t r; struct http_cache_entry *e = arg; DEBUGPRINT ("inside lookup_callback_file for file %s\n", e->name); assert(result != NULL ); /* initiate a read for every regular file */ if ( result->status == NFS3_OK && resok->obj_attributes.attributes_follow && resok->obj_attributes.post_op_attr_u.attributes.type == NF3REG) { /* FIXME: check if the file is recently modified or not. */ // resok->obj_attributes.post_op_attr_u.attributes.ctime; DEBUGPRINT("Copying %s of size %lu\n", e->name, resok->obj_attributes.post_op_attr_u.attributes.size ); /* Store the nfs directory handle in current_session (cs) */ nfs_copyfh (&e->file_handle, resok->object); /* GLOBAL: Storing the global reference for cache entry */ /* NOTE: this memory is freed in reset_cache_entry() */ /* Allocate memory for holding the file-content */ /* Allocate the buff_holder */ e->hbuff = allocate_buff_holder( resok->obj_attributes.post_op_attr_u.attributes.size ); /* NOTE: this memory will be freed by decrement_buff_holder_ref */ /* increment buff_holder reference */ increment_buff_holder_ref (e->hbuff); e->hbuff->len = resok->obj_attributes.post_op_attr_u.attributes.size; /* Set the size of the how much data is read till now. */ e->copied = 0; r = nfs_read (client, e->file_handle, 0, MAX_NFS_READ, read_callback, e); assert (r == ERR_OK); // free arguments xdr_LOOKUP3res(&xdr_free, result); return; } /* Most probably the file does not exist */ DEBUGPRINT ("Error: file [%s] does not exist, or wrong type\n", e->name); #ifdef PRELOAD_WEB_CACHE if (cache_loading_phase){ ++cache_loading_probs; handle_cache_load_done(); return; } #endif // PRELOAD_WEB_CACHE if (e->conn == NULL) { /* No connection is waiting for this loading */ return; } /* as file does not exist, send all the http_conns to error page. */ error_cache->conn = e->conn; error_cache->last = e->last; handle_pending_list (error_cache); /* done! */ /* free this cache entry as it is pointing to invalid page */ e->conn = NULL; e->last = NULL; delete_cacheline_from_cachelist (e); if (e->name != NULL ) free(e->name); free(e); // free arguments xdr_LOOKUP3res(&xdr_free, result); return; } /* end function: lookup_callback_file */
int main(int argc, char** argv) { setbuf(stdout, NULL); if (argc <3) { printf("Usage: ./client.bin -f <init_file>\n"); return -1; } int l_res = 0; char * l_filename = NULL; while( (l_res = getopt(argc, argv, "f:")) != -1) { switch(l_res) { case('f'): { l_filename = optarg; DEBUGPRINT("Prepairing to load init file: %s\n", l_filename); break; } case('?'): { printf("Invalid paramater provided -%i\n", optopt); printf("Usage: ./client.bin -f <init_file>\n"); break; } default: { abort(); break; } } } Network::RobotClient * l_rclient = new Network::RobotClient; l_rclient->init(); RobotParser l_parser; l_res = 0; DEBUGPRINT("About to readfile\n"); if ((l_res = l_parser.readFile(l_filename, (void *)l_rclient )) == ENOENT) { printf("Error with parsing file: %s\n", l_filename); return -1; } if (l_res < 0) { printf("Failed to parse file\n"); return -1; } DEBUGPRINT("Done reading files\n"); l_rclient->initRobotGame(); l_rclient->start(); return 0; }
bool Engine::Network::CNetworkEngine::Update() { if (m_bHost) { Engine::CActor* pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); float fNewLocationX = pcPlayer->GetMetricMember("LocationX"); float fNewLocationY = pcPlayer->GetMetricMember("LocationY"); float fNewLocationZ = pcPlayer->GetMetricMember("LocationZ"); SendPosition(fNewLocationX, fNewLocationY, fNewLocationZ); float fNewRotationX = pcPlayer->GetMetricMember("RotationX"); float fNewRotationY = pcPlayer->GetMetricMember("RotationY"); float fNewRotationZ = pcPlayer->GetMetricMember("RotationZ"); SendRotation(fNewRotationX, fNewRotationY, fNewRotationZ); //Engine::CActor* pcScoreZone1 = m_pcWorld->GetActorByName("ScoreZone1"); //float fScore = pcScoreZone1->GetMetricMember("Score"); //SendScore(fScore); float fStamina = pcPlayer->GetMetricMember("Stamina"); SendStamina(fStamina); float fWalk = pcPlayer->GetMetricMember("SoundWalk"); float fSurface = pcPlayer->GetMetricMember("LastHitSurface"); SendSoundWalk(fWalk == 0.0f ? false : true, fSurface); float fSprint = pcPlayer->GetMetricMember("SoundSprint"); SendSoundSprint(fSprint == 0.0f ? false : true); } else { Engine::CActor* pcPlayer2 = m_pcWorld->GetActorByName("PlayerCube2"); float fNewLocationX = pcPlayer2->GetMetricMember("LocationX"); float fNewLocationY = pcPlayer2->GetMetricMember("LocationY"); float fNewLocationZ = pcPlayer2->GetMetricMember("LocationZ"); SendPosition(fNewLocationX, fNewLocationY, fNewLocationZ); float fNewRotationX = pcPlayer2->GetMetricMember("RotationX"); float fNewRotationY = pcPlayer2->GetMetricMember("RotationY"); float fNewRotationZ = pcPlayer2->GetMetricMember("RotationZ"); SendRotation(fNewRotationX, fNewRotationY, fNewRotationZ); //Engine::CActor* pcScoreZone2 = m_pcWorld->GetActorByName("ScoreZone2"); //float fScore = pcScoreZone2->GetMetricMember("Score"); //SendScore(fScore); float fStamina = pcPlayer2->GetMetricMember("Stamina"); SendStamina(fStamina); float fWalk = pcPlayer2->GetMetricMember("SoundWalk"); float fSurface = pcPlayer2->GetMetricMember("LastHitSurface"); SendSoundWalk(fWalk == 0.0f ? false : true, fSurface); float fSprint = pcPlayer2->GetMetricMember("SoundSprint"); SendSoundSprint(fSprint == 0.0f ? false : true); } for (m_pcPacket = m_pcPeer->Receive(); m_pcPacket; m_pcPeer->DeallocatePacket(m_pcPacket), m_pcPacket = m_pcPeer->Receive()) { switch (m_pcPacket->data[0]) { case ID_REMOTE_DISCONNECTION_NOTIFICATION: DEBUGPRINT("Another client has disconnected.\n"); m_bConnected = false; break; case ID_REMOTE_CONNECTION_LOST: DEBUGPRINT("Another client has lost the connection.\n"); break; case ID_REMOTE_NEW_INCOMING_CONNECTION: DEBUGPRINT("Another client has connected.\n"); m_bConnected = true; break; case ID_CONNECTION_REQUEST_ACCEPTED: { DEBUGPRINT("Our connection request has been accepted.\n"); m_bConnected = true; // Use a BitStream to write a custom user message // Bitstreams are easier to use than sending casted structures, and handle endian swapping automatically RakNet::BitStream bsOut; bsOut.Write((RakNet::MessageID)ID_GAME_VERSION); bsOut.Write(m_sztVersionNumber); m_pcPeer->Send(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, m_pcPacket->systemAddress, false); } break; case ID_NEW_INCOMING_CONNECTION: DEBUGPRINT("A connection is incoming.\n"); m_bConnected = true; break; case ID_NO_FREE_INCOMING_CONNECTIONS: DEBUGPRINT("The server is full.\n"); break; case ID_DISCONNECTION_NOTIFICATION: if (m_bHost) { DEBUGPRINT("A client has disconnected.\n"); } else { DEBUGPRINT("We have been disconnected.\n"); } m_bConnected = false; break; case ID_CONNECTION_LOST: if (m_bHost) { DEBUGPRINT("A client lost the connection.\n"); } else { DEBUGPRINT("Connection lost.\n"); } break; case ID_GAME_VERSION: { memcpy(m_pcSystemAddress, &(m_pcPacket->systemAddress), sizeof(RakNet::SystemAddress)); size_t sztVersion = 0; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(sztVersion); if (m_sztVersionNumber != sztVersion) { if (m_bHost) { DEBUGPRINT("Server is using version %i. Client had version %i. Disconnecting client.\n", m_sztVersionNumber, sztVersion); } else { DEBUGPRINT("Connected to server with matching version of %u\n", sztVersion); } m_pcPeer->CloseConnection(RakNet::AddressOrGUID(m_pcPacket), true); } else { if (m_bHost) { DEBUGPRINT("Client connected to server with matching version of %u\n", m_sztVersionNumber); RakNet::BitStream bsOut; bsOut.Write((RakNet::MessageID)ID_GAME_VERSION); bsOut.Write(m_sztVersionNumber); m_pcPeer->Send(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, m_pcPacket->systemAddress, false); } else { DEBUGPRINT("Connected to server with matching version %i.\n", m_sztVersionNumber); size_t sztNetworkID = 1; RakNet::BitStream bsOut; bsOut.Write((RakNet::MessageID)ID_GAME_SETUP); bsOut.Write(sztNetworkID); m_pcPeer->Send(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, m_pcPacket->systemAddress, false); } } } break; case ID_GAME_SETUP: { if (m_bHost) { Engine::CActor* pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); Engine::CActor* pcPlayer2 = m_pcWorld->GetActorByName("PlayerCube2"); pcPlayer->SetDataMember("Status", "Enabled"); pcPlayer->SetDataMember("NetworkControl", "Enabled"); pcPlayer->SetMetricMember("LocationX", 0.0f); pcPlayer->SetMetricMember("LocationY", 0.0f); pcPlayer->SetMetricMember("LocationZ", -500.0f); pcPlayer->SetMetricMember("RotationX", 0.0f); pcPlayer->SetMetricMember("RotationY", 0.0f); pcPlayer->SetMetricMember("RotationZ", 0.0f); pcPlayer2->SetDataMember("Status", "Enabled"); pcPlayer2->SetDataMember("NetworkControl", "Disabled"); pcPlayer2->SetMetricMember("LocationX", 0.0f); pcPlayer2->SetMetricMember("LocationY", 0.0f); pcPlayer2->SetMetricMember("LocationZ", 500.0f); pcPlayer2->SetMetricMember("RotationX", 0.0f); pcPlayer2->SetMetricMember("RotationY", 180.0f); pcPlayer2->SetMetricMember("RotationZ", 0.0f); Engine::CActor* pcPlayer2Forward = m_pcWorld->GetActorByName("Player2Forward"); pcPlayer2Forward->SetDataMember("Status", "Enabled"); Engine::CActor* pcCamera = m_pcWorld->GetActorByName("Camera"); Engine::CActor* pcCamera2 = m_pcWorld->GetActorByName("Camera2"); pcCamera->SetDataMember("CameraStatus", "Enabled"); pcCamera2->SetDataMember("CameraStatus", "Disabled"); pcCamera->SetDataMember("LookAtStatus", "Enabled"); pcCamera2->SetDataMember("LookAtStatus", "Disabled"); Engine::CActor* pcScoreZone1 = m_pcWorld->GetActorByName("ScoreZone1"); Engine::CActor* pcScoreZone2 = m_pcWorld->GetActorByName("ScoreZone2"); pcScoreZone1->SetMetricMember("Score", 0.0f); pcScoreZone2->SetMetricMember("Score", 0.0f); pcScoreZone1->SetDataMember("TextStatus", "Enabled"); pcScoreZone2->SetDataMember("TextStatus", "Enabled"); size_t sztNetworkID = 2; RakNet::BitStream bsOut; bsOut.Write((RakNet::MessageID)ID_GAME_SETUP); bsOut.Write(sztNetworkID); m_pcPeer->Send(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, m_pcPacket->systemAddress, false); } else { Engine::CActor* pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); Engine::CActor* pcPlayer2 = m_pcWorld->GetActorByName("PlayerCube2"); pcPlayer->SetDataMember("Status", "Enabled"); pcPlayer->SetDataMember("NetworkControl", "Disabled"); pcPlayer->SetMetricMember("LocationX", 0.0f); pcPlayer->SetMetricMember("LocationY", 0.0f); pcPlayer->SetMetricMember("LocationZ", -500.0f); pcPlayer->SetMetricMember("RotationX", 0.0f); pcPlayer->SetMetricMember("RotationY", 0.0f); pcPlayer->SetMetricMember("RotationZ", 0.0f); pcPlayer2->SetDataMember("Status", "Enabled"); pcPlayer2->SetDataMember("NetworkControl", "Enabled"); pcPlayer2->SetDataMember("Status", "Enabled"); pcPlayer2->SetMetricMember("LocationX", 0.0f); pcPlayer2->SetMetricMember("LocationY", 0.0f); pcPlayer2->SetMetricMember("LocationZ", 500.0f); pcPlayer2->SetMetricMember("RotationX", 0.0f); pcPlayer2->SetMetricMember("RotationY", 180.0f); pcPlayer2->SetMetricMember("RotationZ", 0.0f); pcPlayer2->SetInputMember("MovePositiveX", pcPlayer->GetInputMember("MovePositiveX")); pcPlayer2->SetInputMember("MovePositiveY", pcPlayer->GetInputMember("MovePositiveY")); pcPlayer2->SetInputMember("MovePositiveZ", pcPlayer->GetInputMember("MovePositiveZ")); pcPlayer2->SetInputMember("MoveNegativeX", pcPlayer->GetInputMember("MoveNegativeX")); pcPlayer2->SetInputMember("MoveNegativeY", pcPlayer->GetInputMember("MoveNegativeY")); pcPlayer2->SetInputMember("MoveNegativeZ", pcPlayer->GetInputMember("MoveNegativeZ")); pcPlayer2->SetInputMember("Run", pcPlayer->GetInputMember("Run")); Engine::CActor* pcCamera = m_pcWorld->GetActorByName("Camera"); Engine::CActor* pcCamera2 = m_pcWorld->GetActorByName("Camera2"); pcCamera->SetDataMember("CameraStatus", "Disabled"); pcCamera2->SetDataMember("CameraStatus", "Enabled"); pcCamera->SetDataMember("LookAtStatus", "Disabled"); pcCamera2->SetDataMember("LookAtStatus", "Enabled"); Engine::CActor* pcScoreZone1 = m_pcWorld->GetActorByName("ScoreZone1"); Engine::CActor* pcScoreZone2 = m_pcWorld->GetActorByName("ScoreZone2"); pcScoreZone1->SetMetricMember("Score", 0.0f); pcScoreZone2->SetMetricMember("Score", 0.0f); pcScoreZone1->SetDataMember("TextStatus", "Enabled"); pcScoreZone2->SetDataMember("TextStatus", "Enabled"); Engine::CActor* pcStaminaBar1 = m_pcWorld->GetActorByName("StaminaBar1"); pcStaminaBar1->SetDataMember("ActiveState", "Game"); Engine::CActor* pcStaminaBar2 = m_pcWorld->GetActorByName("StaminaBar2"); pcStaminaBar2->SetDataMember("ActiveState", "Game"); Engine::CActor* pcPlayer2Forward = m_pcWorld->GetActorByName("Player2Forward"); pcPlayer2Forward->SetDataMember("Status", "Enabled"); } } break; case ID_GAME_POSITION: { if (m_bHost) { float fX = 0.0f; float fY = 0.0f; float fZ = 0.0f; float fLastHit = 0.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fX); bsIn.Read(fY); bsIn.Read(fZ); Engine::CActor* pcPlayer2 = m_pcWorld->GetActorByName("PlayerCube2"); pcPlayer2->SetMetricMember("LocationX", fX); pcPlayer2->SetMetricMember("LocationY", fY); pcPlayer2->SetMetricMember("LocationZ", fZ); m_pcWorld->ResetTimer(); } else { float fX = 0.0f; float fY = 0.0f; float fZ = 0.0f; float fPlaySound = -1.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fX); bsIn.Read(fY); bsIn.Read(fZ); Engine::CActor* pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); pcPlayer->SetMetricMember("LocationX", fX); pcPlayer->SetMetricMember("LocationY", fY); pcPlayer->SetMetricMember("LocationZ", fZ); m_pcWorld->ResetTimer(); } } break; case ID_GAME_ROTATION: { if (m_bHost) { float fX = 0.0f; float fY = 0.0f; float fZ = 0.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fX); bsIn.Read(fY); bsIn.Read(fZ); Engine::CActor* pcPlayer2 = m_pcWorld->GetActorByName("PlayerCube2"); pcPlayer2->SetMetricMember("RotationX", fX); pcPlayer2->SetMetricMember("RotationY", fY); pcPlayer2->SetMetricMember("RotationZ", fZ); m_pcWorld->ResetTimer(); } else { float fX = 0.0f; float fY = 0.0f; float fZ = 0.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fX); bsIn.Read(fY); bsIn.Read(fZ); Engine::CActor* pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); pcPlayer->SetMetricMember("RotationX", fX); pcPlayer->SetMetricMember("RotationY", fY); pcPlayer->SetMetricMember("RotationZ", fZ); m_pcWorld->ResetTimer(); } } break; case ID_GAME_SCORE: { if (m_bHost) { float fScore = 0.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fScore); Engine::CActor* pcScoreZone2 = m_pcWorld->GetActorByName("ScoreZone2"); pcScoreZone2->SetMetricMember("Score", fScore); m_pcWorld->ResetTimer(); } else { float fScore = 0.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fScore); Engine::CActor* pcScoreZone1 = m_pcWorld->GetActorByName("ScoreZone1"); pcScoreZone1->SetMetricMember("Score", fScore); m_pcWorld->ResetTimer(); } } break; case ID_GAME_STAMINA: { if (m_bHost) { float fStamina = 0.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fStamina); Engine::CActor* pcPlayer2 = m_pcWorld->GetActorByName("PlayerCube2"); pcPlayer2->SetMetricMember("Stamina", fStamina); m_pcWorld->ResetTimer(); } else { float fStamina = 0.0f; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(fStamina); Engine::CActor* pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); pcPlayer->SetMetricMember("Stamina", fStamina); m_pcWorld->ResetTimer(); } } break; case ID_SOUND_SPRINT: { bool bSprint = false; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(bSprint); if (bSprint) { if (eae6320::UserSettings::IsSoundOn()) { Engine::CActor* pcPlayer = nullptr; if (m_bHost) { pcPlayer = m_pcWorld->GetActorByName("PlayerCube2"); } else { pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); } float fX = pcPlayer->GetMetricMember("LocationX"); float fY = pcPlayer->GetMetricMember("LocationY"); float fZ = pcPlayer->GetMetricMember("LocationZ"); Shared::Math::CVector3 v3Position(fX, fY, fZ); Shared::Math::CVector3 v3Velocity(0.0f, 0.0f, 0.0f); m_pcSoundEngine->Play3D(m_pcSprintSound, m_pcSprintChannel, v3Position, v3Velocity); m_pcSoundEngine->SetVolume(50.0f * eae6320::UserSettings::GetSoundVolumeLevel(), m_pcSprintChannel); } } else { m_pcSoundEngine->Stop(m_pcSprintChannel); } m_pcWorld->ResetTimer(); } break; case ID_SOUND_WALK: { float fSurface = -1.0f; bool bWalk = false; RakNet::BitStream bsIn(m_pcPacket->data, m_pcPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(bWalk); bsIn.Read(fSurface); if (bWalk) { Engine::CActor* pcPlayer = nullptr; if (m_bHost) { pcPlayer = m_pcWorld->GetActorByName("PlayerCube2"); } else { pcPlayer = m_pcWorld->GetActorByName("PlayerCube"); } float fX = pcPlayer->GetMetricMember("LocationX"); float fY = pcPlayer->GetMetricMember("LocationY"); float fZ = pcPlayer->GetMetricMember("LocationZ"); Shared::Math::CVector3 v3Position(fX, fY, fZ); Shared::Math::CVector3 v3Velocity(0.0f, 0.0f, 0.0f); switch (static_cast<int>(fSurface)) { case 0: if (eae6320::UserSettings::IsSoundOn()) { m_pcSoundEngine->Play3D(m_pcGroundSound, m_pcGroundChannel, v3Position, v3Velocity); m_pcSoundEngine->SetVolume(1.0f * eae6320::UserSettings::GetSoundVolumeLevel(), m_pcGroundChannel); } m_pcSoundEngine->Stop(m_pcStairChannel); break; case 1: if (eae6320::UserSettings::IsSoundOn()) { m_pcSoundEngine->Play3D(m_pcStairSound, m_pcStairChannel, v3Position, v3Velocity); m_pcSoundEngine->SetVolume(1.0f * eae6320::UserSettings::GetSoundVolumeLevel(), m_pcStairChannel); } m_pcSoundEngine->Stop(m_pcGroundChannel); break; default: m_pcSoundEngine->Stop(m_pcGroundChannel); m_pcSoundEngine->Stop(m_pcStairChannel); break; } } else { m_pcSoundEngine->Stop(m_pcGroundChannel); m_pcSoundEngine->Stop(m_pcStairChannel); } m_pcWorld->ResetTimer(); } break; default: DEBUGPRINT("Message with identifier %i has arrived.\n", m_pcPacket->data[0]); break; } } return true; }
//thread to listen for connect requests void *AgentListenThread(void *arg) { pthread_t rxThread[MAX_AGENT_CONNECTIONS]; struct sockaddr client_address; socklen_t client_address_len; //initialize the data structures { for (int i=0; i<MAX_AGENT_CONNECTIONS; i++) { rxSocket[i] = -1; txSocket[i] = -1; rxThread[i] = (pthread_t) -1; connected[i] = false; } } DEBUGPRINT("agent: Listen thread\n"); //create listen socket int listenSocket; while ((listenSocket = socket(AF_INET, SOCK_STREAM, 0)) == -1) { ERRORPRINT("agent: socket() error: %s\n", strerror(errno)); sleep(1); } int optval = 1; setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, &optval, 4); DEBUGPRINT("agent: listen socket created\n"); //bind socket address struct sockaddr_in my_address; memset(&my_address, 0, sizeof(my_address)); my_address.sin_family = AF_INET; my_address.sin_port = htons(LISTEN_PORT_NUMBER); my_address.sin_addr.s_addr = INADDR_ANY; while (bind(listenSocket, (struct sockaddr*) &my_address, sizeof(my_address)) == -1) { ERRORPRINT("agent: bind() error: %s\n", strerror(errno)); if (errno == EADDRINUSE) sleep(10); sleep(1); } DEBUGPRINT("agent: listen socket ready\n"); while(1) { //wait for connect while(listen(listenSocket, 2) != 0) { ERRORPRINT("agent: listen() error %s\n", strerror(errno)); sleep(1); //ignore errors, just retry } client_address_len = sizeof(client_address); int acceptSocket = accept(listenSocket, &client_address, &client_address_len); if (acceptSocket >= 0) { //print the address struct sockaddr_in *client_address_in = (struct sockaddr_in *) &client_address; uint8_t addrBytes[4]; memcpy(addrBytes, &client_address_in->sin_addr.s_addr, 4); DEBUGPRINT("agent: connect from %i.%i.%i.%i\n", addrBytes[0], addrBytes[1], addrBytes[2], addrBytes[3]); //find a free thread int i; int channel = -1; for (i=0; i<MAX_AGENT_CONNECTIONS; i++) { if (!connected[i]) { channel = i; break; } } if (channel < 0) { pthread_mutex_unlock(&agentMtx); DEBUGPRINT("agent: no available server context\n"); } else { rxSocket[channel] = acceptSocket; txSocket[channel] = dup(acceptSocket); //separate rx & tx sockets //create agent Rx thread int s; do { s = pthread_create(&rxThread[channel], NULL, AgentRxThread, (void*) channel); if (s == EAGAIN) sleep(1); } while (s == EAGAIN); if (s != 0) { LogError("agent: Rx %i create failed - %s\n", channel, strerror(s)); close(rxSocket[channel]); close(txSocket[channel]); } else { DEBUGPRINT("agent: Rx %i thread created.\n", channel); } } } } return 0; }
extern "C" void __DebugMsgWaitForAnyRequest() { __KTRACE_OPT(KEXEC,DEBUGPRINT("WfAR")); }
//thread function for Rx void *AgentRxThread(void *arg) { int mychan = (int) arg; int socket = rxSocket[mychan]; psMessage_t rxMessage; status_t parseStatus; DEBUGPRINT("agent: Rx %i thread: fd=%i\n",mychan, socket); parseStatus.noCRC = 0; ///< Do not expect a CRC, if > 0 parseStatus.noSeq = 0; ///< Do not check seq #s, if > 0 parseStatus.noLength2 = 0; ///< Do not check for duplicate length, if > 0 parseStatus.noTopic = 1; ///< Do not check for topic ID, if > 0 ResetParseStatus(&parseStatus); agentOnline++; connected[mychan] = true; while(connected[mychan]) { uint8_t readByte; int result; do { if (recv(socket, &readByte, 1, 0) <= 0) { //quit on failure, EOF, etc. ERRORPRINT("agent: Rx %i recv(fd=%i) error: %s\n", mychan, socket, strerror(errno)); AGENTreceiveErrors++; pthread_mutex_lock(&agentMtx); close(socket); rxSocket[mychan] = -1; close(txSocket[mychan]); txSocket[mychan] = -1; connected[mychan] = false; agentOnline--; pthread_mutex_unlock(&agentMtx); pthread_exit(NULL); return 0; } result = ParseNextCharacter(readByte, &rxMessage, &parseStatus); } while (result == 0); if (rxMessage.header.messageType == KEEPALIVE) { if (loopback) { rxMessage.header.source = 0; CopyMessageToQ(&agentQueue, &rxMessage); } else { rxMessage.header.source = APP_XBEE; XBeeBrokerProcessMessage(&rxMessage); } } else { DEBUGPRINT("agent: Rx %i. %s message received\n", mychan, psLongMsgNames[rxMessage.header.messageType]); AGENTmessagesReceived++; rxMessage.header.source = APP_XBEE; RouteMessage(&rxMessage); } } //Tx disconnected DEBUGPRINT("agent: Rx %i exiting.\n", mychan); pthread_mutex_lock(&agentMtx); close(socket); rxSocket[mychan] = -1; agentOnline--; pthread_mutex_unlock(&agentMtx); pthread_exit(NULL); return 0; }
extern "C" void __DebugMsgRR(int a) { NThread* pT=(NThread*)a; __KTRACE_OPT(KSCHED2,DEBUGPRINT("RoundRobin->%T",pT)); }
//Tx thread function void *AgentTxThread(void *arg) { int errorReply = 0; int checksum; uint8_t msgSequence[MAX_AGENT_CONNECTIONS]; for (int i=0; i<MAX_AGENT_CONNECTIONS; i++) msgSequence[i] = 0; //loop while (1) { //wait for next message psMessage_t *txMessage = GetNextMessage(&agentQueue); for (int i=0; i<MAX_AGENT_CONNECTIONS; i++) { if (connected[i]) { pthread_mutex_lock(&agentMtx); int socket = txSocket[i]; //send STX writeToSocket( socket, STX_CHAR, &checksum, &errorReply); checksum = 0; //checksum starts from here //send header writeToSocket( socket, txMessage->header.length, &checksum, &errorReply); writeToSocket( socket, ~txMessage->header.length, &checksum, &errorReply); writeToSocket( socket, msgSequence[i]++, &checksum, &errorReply); writeToSocket( socket, txMessage->header.source, &checksum, &errorReply); writeToSocket( socket, txMessage->header.messageType, &checksum, &errorReply); //send payload uint8_t *buffer = (uint8_t *) &txMessage->packet; uint8_t size = txMessage->header.length; if (size > sizeof(psMessage_t) - SIZEOF_HEADER) { size = txMessage->header.length = sizeof(psMessage_t) - SIZEOF_HEADER; } while (size) { writeToSocket( socket, *buffer, &checksum, &errorReply); buffer++; size--; } //write checksum writeToSocket( socket, (checksum & 0xff), &checksum, &errorReply); if (errorReply != 0) { ERRORPRINT("agent: Tx send error: %s\n", strerror(errno)); AGENTsendErrors; close(socket); txSocket[i] = -1; connected[i] = false; } else { DEBUGPRINT("agent: %s message sent\n", psLongMsgNames[txMessage->header.messageType]); AGENTmessagesSent++; if (psDefaultTopics[txMessage->header.messageType] == LOG_TOPIC) { switch (txMessage->logPayload.severity) { case SYSLOG_INFO: agentInfo--; break; case SYSLOG_WARNING: agentWarning--; break; case SYSLOG_ERROR: agentError--; default: break; } } } pthread_mutex_unlock(&agentMtx); } } DoneWithMessage(txMessage); } return 0; }
extern "C" void __DebugMsgImpSysHeld(int a) { NThread* pT=(NThread*)a; __KTRACE_OPT(KSCHED2,DEBUGPRINT("Resched inter->%T (IMP SYS)",pT)); }
void CPicoServSession::loadROM() { TInt res; const TAny* pD=Message().Ptr0(); // TInt desLen=Message().Client().GetDesLength(pD); if(rom_data) { // save SRAM for previous ROM if(currentConfig.iFlags & 1) saveLoadGame(0, 1); } RomFileName = 0; if(rom_data) { free(rom_data); rom_data = 0; } // read the contents of the client pointer into a TPtr. static TBuf8<KMaxFileName> writeBuf; TRAP(res,Message().ReadL(pD,writeBuf)); if (res!=KErrNone) { PanicClient(EBadDescriptor); return; } // detect wrong extensions (.srm and .mds) TBuf8<5> ext; ext.Copy(writeBuf.Right(4)); ext.LowerCase(); if(!strcmp((char *)ext.PtrZ(), ".srm") || !strcmp((char *)ext.PtrZ(), "s.gz") || // .mds.gz !strcmp((char *)ext.PtrZ(), ".mds")) { User::Leave(3); return; } FILE *rom = fopen((char *) writeBuf.PtrZ(), "rb"); if(!rom) { DEBUGPRINT(_L("failed to open rom.")); User::Leave(1); return; } unsigned int rom_size = 0; // zipfile support if(!strcmp((char *)ext.PtrZ(), ".zip")) { fclose(rom); res = CartLoadZip((const char *) writeBuf.PtrZ(), &rom_data, &rom_size); if(res) { User::Leave(res); return; } } else { if( (res = PicoCartLoad(rom, &rom_data, &rom_size)) ) { DEBUGPRINT(_L("PicoCartLoad() failed.")); fclose(rom); User::Leave(2); return; } fclose(rom); } // detect wrong files (Pico crashes on very small files), also see if ROM EP is good if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 || ((*(TUint16 *)(rom_data+4)<<16)|(*(TUint16 *)(rom_data+6))) >= (int)rom_size) { free(rom_data); rom_data = 0; User::Leave(3); // not a ROM } DEBUGPRINT(_L("PicoCartInsert(0x%08X, %d);"), rom_data, rom_size); if(PicoCartInsert(rom_data, rom_size)) { User::Leave(2); return; } pico_was_reset = 1; // global ROM file name for later use RomFileName = (const char *) writeBuf.PtrZ(); // load SRAM for this ROM if(currentConfig.iFlags & 1) saveLoadGame(1, 1); // debug #ifdef __DEBUG_PRINT TInt cells = User::CountAllocCells(); TInt mem; User::AllocSize(mem); DEBUGPRINT(_L("comm: cels=%d, size=%d KB"), cells, mem/1024); gamestate = PGS_DebugHeap; gamestate_prev = PGS_Running; #else gamestate = PGS_Running; #endif }
extern "C" void DebugMsgNKFMWait(int a) { __NK_ASSERT_DEBUG(!TheScheduler.iCurrentThread->iHeldFastMutex); __KTRACE_OPT(KNKERN,DEBUGPRINT("NKFMWait %M",a)); }
// service a client request; test the opcode and then do appropriate servicing void CPicoServSession::DispatchMessageL(const RMessage &aMessage) { switch (aMessage.Function()) { case PicoMsgLoadState: if(!rom_data) User::Leave(-1); // no ROM User::LeaveIfError(saveLoadGame(1)); gamestate = PGS_Running; return; case PicoMsgSaveState: if(!rom_data) User::Leave(-1); User::LeaveIfError(saveLoadGame(0)); gamestate = PGS_Running; return; case PicoMsgLoadROM: loadROM(); return; case PicoMsgResume: if(rom_data) gamestate = PGS_Running; return; case PicoMsgReset: if(rom_data) { PicoReset(0); pico_was_reset = 1; gamestate = PGS_Running; } return; case PicoMsgKeys: gamestate = PGS_KeyConfig; return; case PicoMsgPause: gamestate = PGS_Paused; return; case PicoMsgQuit: DEBUGPRINT(_L("got quit msg.")); gamestate = PGS_Quit; return; // config change case PicoMsgConfigChange: // launcher -> emu changeConfig(); return; case PicoMsgRetrieveConfig: // emu -> launcher sendConfig(); return; case PicoMsgRetrieveDebugStr: // emu -> launcher sendDebug(); return; // requests we don't understand at all are a different thing, // so panic the client here, this function also completes the message default: PanicClient(EBadRequest); return; } }
int main(int argc,char * argv[]) { char *printer; char ppd_line[500],tmp[500],*p_tmp,tmp_n[10],tmp_op[500]; FILE *fp_ppd; char *p; char *commandline,*ppdfile; int i,ii; #ifdef _CUSTOM_TAPE_ TapeItem tapeitem; #endif DEBUGPRINT("main:start\n"); // fprintf (stderr, "ERROR: brcupsconfpt1 pid=%d\n", getpid()); // sleep(100); #ifdef _CUSTOM_TAPE_ memset(&g_tapelist, 0, sizeof(TapeList)); g_tapelist.iSelIndex = -1; #endif if(argc < 1){ return 0; } printer = argv[1]; if(argc > 2){ ppdfile= argv[2]; } else{ ppdfile=""; } // fprintf(stderr, "ERROR: pid=%d\n", getpid()); // sleep(1000); if(argc > 3){ if(argv[3][0] >= '0' && argv[3][0] <= '9'){ log_level = argv[3][0] -'0'; } else{ log_level = 0; } } else{ log_level = 0; } if(argc > 4){ commandline = argv[4]; } else{ commandline = "NULL COMMAND LINE"; } fp_ppd = fopen(ppdfile , "r"); if( fp_ppd == NULL) return 0; initialize_command_list(); //************************************ // set default setting //************************************ DEBUGPRINT("main:set default setting\n"); write_log_file(5,"DEFAULT SETTING\n"); for ( i = 0; default_setting[i] != NULL; i ++){ p = strstr_ex(default_setting[i],"BROTHERPRINTER_XXX"); if(p){ p = strchr(p,'-'); if(p){ add_command_list_brcommand(p); } } } //************************************ // set PPD option //************************************ DEBUGPRINT("main:set PPD option (string)\n"); write_log_file(5,"PPD SETTING\n"); #ifdef _CUSTOM_TAPE_ // TapeItem tapeitem; while(fgets(ppd_line,sizeof(ppd_line),fp_ppd)) { if(NULL == delete_ppd_comment(ppd_line)) continue; if( 1 == GetLabel_name_id(ppd_line, tapeitem.tape_name, tapeitem.tape_id) ) { add_tape(&g_tapelist, tapeitem.tape_name, tapeitem.tape_id); } } rewind(fp_ppd); #endif while(fgets(ppd_line,sizeof(ppd_line),fp_ppd)){ if(NULL == delete_ppd_comment(ppd_line))continue; if(NULL == chk_ppd_default_setting_line(ppd_line))continue; //************************************ // set PPD option (string) //************************************ for ( i = 0; ppdcommand_all_list[i]!= NULL; i ++) { //DEBUGPRINT2( "main: set PPD option (string) [%s] [%s]\n", // ppd_line,ppdcommand_all_list[i]->label); p = strstr_ex(ppd_line,ppdcommand_all_list[i]->label); if(p) { //DEBUGPRINT2( "main: set PPD option (string) [%s] [%s]\n", // ppdcommand_all_list[i]->label,ppd_line); for (ii = 0; ppdcommand_all_list[i]->ppdcommandlist[ii].value != NULL; ii++) { //DEBUGPRINT3( "main: set PPD option (string) [%s] [%s] [%s]\n", // ppdcommand_all_list[i]->label,ppdcommand_all_list[i]->ppdcommandlist[ii].value , ppd_line); p = strstr_ex(ppd_line,ppdcommand_all_list[i]->ppdcommandlist[ii].value); if(p) { add_command_list_brcommand(ppdcommand_all_list[i]->ppdcommandlist[ii].brcommand); break; } } #ifdef _CUSTOM_TAPE_ if( strcmp(ppdcommand_all_list[i]->label, "DefaultPageSize") == 0 ) { for( ii = 0; ii < g_tapelist.count; ii++ ) { p = strstr_ex(ppd_line, g_tapelist.tapelist[ii].tape_id); if(p) { char lp[512]; sprintf(lp, "-media %s", g_tapelist.tapelist[ii].tape_name); add_command_list_brcommand(lp); break; } } } #endif } } //************************************ // set PPD option (numerical) //************************************ for ( i = 0; PPDdefaultN[i].option!= NULL; i ++){ strcpy(tmp,PPDdefaultN[i].option); p_tmp = tmp; if(tmp[0] == '^')p_tmp ++; p = strstr_ex(ppd_line,p_tmp); if(p){ //DEBUGPRINT2( "main: set PPD option (numerical) [%s] [%s]\n", // ppd_line,p_tmp); sprintf(tmp,"%s %s",PPDdefaultN[i].value, p + strlen(PPDdefaultN[i].option)); //DEBUGPRINT1("set commandline option(n) ********** : [%s]\n",tmp); get_token(PPDdefaultN[i].value ,tmp_op); get_token(p + strlen(PPDdefaultN[i].option) ,tmp_n); add_command_list(tmp_op,tmp_n); } } } //************************************ // set brother command line option (string) //************************************ DEBUGPRINT("main:set brother command line option (string)\n"); write_log_file(5,"BROTHER COMMAND LINE SETTING(S)\n"); for ( i = 0; commandlinelist[i].value != NULL; i ++){ //DEBUGPRINT2("main:set command line option (string) Loop [%s] [%s]\n", // commandline,commandlinelist[i].value ); p = strstr_ex(commandline,commandlinelist[i].option); if(p){ add_command_list_brcommand(commandlinelist[i].value); } } //************************************ // set cups standard command line option (duplex) //************************************ DEBUGPRINT("main:set standard command line option (duplex)\n"); write_log_file(5,"STANDARD COMMAND LINE SETTING(DUPLEX)\n"); for ( i = 0; standard_side_commandlinelist[i].value != NULL; i ++){ //DEBUGPRINT2("main:set command line option (duplex) Loop [%s] [%s]\n", // commandline,standard_side_commandlinelist[i].option ); p = strstr_ex(commandline,standard_side_commandlinelist[i].option); if(p){ add_command_list_brcommand(standard_side_commandlinelist[i].value); } } //************************************ // set cups standard command line option (media ) //************************************ DEBUGPRINT("main:set standard command line option (media)\n"); write_log_file(5,"STANDARD COMMAND LINE SETTING(MEDIA)\n"); { char output[5][30]; int max; max = divide_media_token(commandline,output); //DEBUGPRINT2("main:set command line option (media) Loop count %d %s \n", // max,commandline); for ( ii=0; ii < max; ii++){ // for ( i = 0; standard_media_commandlinelist[i].value != NULL; i ++){ for ( i = 0; standard_commandlinelist[i].value != NULL; i ++){ //DEBUGPRINT2("main:set command line option (media) Loop [%s] [%s]\n", // output[ii],standard_media_commandlinelist[i].option); p = strstr(standard_commandlinelist[i].option, output[ii]); if(p){ add_command_list_brcommand(standard_commandlinelist[i].value); } } #ifdef _CUSTOM_TAPE_ for ( i = 0; i < g_tapelist.count; i++) { // modified by Liu Bin 2006.2.20 char lp[512]; p = strstr(output[ii], g_tapelist.tapelist[i].tape_name); if(p) // when the user uses the tool to set media { sprintf(lp, "-media \"%s\"", g_tapelist.tapelist[i].tape_name); add_command_list_brcommand(lp); } else { p = strstr(output[ii], g_tapelist.tapelist[i].tape_id); if(p) // when the printing system uses the tool to set media { sprintf(lp, "-media \"%s\"", g_tapelist.tapelist[i].tape_name); add_command_list_brcommand(lp); } } } #endif } } //************************************ // set command line option (numerical) //************************************ DEBUGPRINT("main:set command line option (numerical)\n"); write_log_file(5,"COMMAND LINE SETTING(N)\n"); for(i = 0; commandlinelist2[i].option != NULL; i ++){ p = strstr_ex(commandline,commandlinelist2[i].option); //DEBUGPRINT3("set commandline option(n) : [%s] [%s] [%s]\n" // ,commandline,commandlinelist2[i].option,p); if(p){ //DEBUGPRINT3("set commandline option(n) 1 ********** : [%s] [%s] [%s]\n" // ,tmp_n,p + strlen(commandlinelist2[i].option),p); get_token(commandlinelist2[i].value ,tmp_op); get_token(p + strlen(commandlinelist2[i].option) ,tmp_n); sprintf(tmp,"%s %s",tmp_op,tmp_n ); //DEBUGPRINT2("set commandline option(n) 2 ********** : [%s] [%s]\n" // ,tmp_op,tmp_n); add_command_list(tmp_op,tmp_n); } } //************************************ // call brprintconf //************************************ exec_brprintconf(brprintconf,printer); return 0; }
char xhextrisExposeEvent(XExposeEvent *ev){ DEBUGPRINT(("Exp: '%d'\n",ev->window));; return ((ev->count) ? 0 : 'r'); }
int main (int argc, char *argv[]) { const char *snapshot; atexit(shutdown_sdl); if (SDL_Init( #ifdef __EMSCRIPTEN__ // It seems there is an issue with emscripten SDL2: SDL_Init does not work if TIMER and/or HAPTIC is tried to be intialized or just "EVERYTHING" is used!! SDL_INIT_EVERYTHING & ~(SDL_INIT_TIMER | SDL_INIT_HAPTIC) #else SDL_INIT_EVERYTHING #endif ) != 0) { ERROR_WINDOW("Fatal SDL initialization problem: %s", SDL_GetError()); return 1; } if (config_init(argc, argv)) { #ifdef __EMSCRIPTEN__ ERROR_WINDOW("Error with config parsing. Please check the (javascript) console of your browser to learn about the error."); #endif return 1; } guarded_exit = 1; // turn on guarded exit, with custom de-init stuffs DEBUGPRINT("EMU: sleeping = \"%s\", timing = \"%s\"" NL, __SLEEP_METHOD_DESC, __TIMING_METHOD_DESC ); fileio_init( #ifdef __EMSCRIPTEN__ "/", #else app_pref_path, #endif "files"); if (screen_init()) return 1; if (xepgui_init()) return 1; audio_init(config_getopt_int("audio")); z80ex_init(); set_ep_cpu(CPU_Z80); ep_pixels = nick_init(); if (ep_pixels == NULL) return 1; snapshot = config_getopt_str("snapshot"); if (strcmp(snapshot, "none")) { if (ep128snap_load(snapshot)) snapshot = NULL; } else snapshot = NULL; if (!snapshot) { if (roms_load()) return 1; primo_rom_seg = primo_search_rom(); ep_set_ram_config(config_getopt_str("ram")); } mouse_setup(config_getopt_int("mousemode")); ep_reset(); kbd_matrix_reset(); joy_sdl_event(NULL); // this simply inits joy layer ... #ifdef CONFIG_SDEXT_SUPPORT if (!snapshot) sdext_init(); #endif #ifdef CONFIG_EXDOS_SUPPORT wd_exdos_reset(); wd_attach_disk_image(config_getopt_str("wdimg")); #endif #ifdef CONFIG_W5300_SUPPORT w5300_init(NULL); #endif ticks = SDL_GetTicks(); balancer = 0; set_cpu_clock(DEFAULT_CPU_CLOCK); emu_timekeeping_start(); audio_start(); if (config_getopt_int("fullscreen")) screen_set_fullscreen(1); DEBUGPRINT(NL "EMU: entering into main emulation loop" NL); sram_ready = 1; if (strcmp(config_getopt_str("primo"), "none") && !snapshot) { // TODO: da stuff ... primo_emulator_execute(); OSD("Primo Emulator Mode"); } if (snapshot) ep128snap_set_cpu_and_io(); console_monitor_ready(); // OK to run monitor on console now! #ifdef __EMSCRIPTEN__ emscripten_set_main_loop(xep128_emulation, 50, 1); #else for (;;) xep128_emulation(); #endif printf("EXITING FROM main()?!" NL); return 0; }
int config_init ( int argc, char **argv ) { const char *config_name = DEFAULT_CONFIG_FILE; // name of the used config file, can be overwritten via CLI const struct configOption_st *opt; const char *exe = argv[0]; int default_config = 1; int testparsing = 0; argc--; argv++; #ifdef __EMSCRIPTEN__ exe = strdup("/files/emscripten-virtual-executable"); #endif #ifdef _WIN32 console_open_window(); #endif SDL_VERSION(&sdlver_compiled); SDL_GetVersion(&sdlver_linked); if (sdlver_linked.major < 2 || (sdlver_linked.minor == 0 && sdlver_linked.patch < 4)) { ERROR_WINDOW("Too old SDL library linked, at least version 2.0.4 is required."); return 1; } /* SDL info on paths */ if (get_path_info()) return 1; /* ugly hack: pre-parse comand line to find debug statement (to be worse, it does not handle single argument options too well ... */ #ifdef DISABLE_DEBUG printf("DEBUG: disabled at compilation time." NL); #else while (testparsing < argc) { if (!strcmp(argv[testparsing], "-" DEBUGFILE_OPT) && testparsing != argc - 1 && strcmp(argv[testparsing + 1], "none")) { debug_fp = fopen(argv[testparsing + 1], "w"); DEBUGPRINT("DEBUG: enable logging into file: %s" NL, argv[testparsing + 1]); if (debug_fp == NULL) fprintf(stderr, "Cannot open debug logging file: %s" NL, argv[testparsing + 1]); break; } testparsing++; } testparsing = 0; #endif /* end of ugly hack */ /* let's continue with the info block ... */ DEBUGPRINT("%s %s v%s %s %s" NL "GIT %s compiled by (%s) at (%s) with (%s)-(%s)" NL "Platform: (%s) (%d-bit), video: (%s), audio: (%s), " "SDL version compiled: (%d.%d.%d) and linked: (%d.%d.%d) rev (%s)" NL NL, WINDOW_TITLE, DESCRIPTION, VERSION, COPYRIGHT, PROJECT_PAGE, XEMU_BUILDINFO_GIT, XEMU_BUILDINFO_ON, XEMU_BUILDINFO_AT, CC_TYPE, XEMU_BUILDINFO_CC, SDL_GetPlatform(), ARCH_BITS, SDL_GetCurrentVideoDriver(), SDL_GetCurrentAudioDriver(), sdlver_compiled.major, sdlver_compiled.minor, sdlver_compiled.patch, sdlver_linked.major, sdlver_linked.minor, sdlver_linked.patch, SDL_GetRevision() ); DEBUGPRINT("PATH: executable: %s" NL, exe); /* SDL path info block printout */ DEBUGPRINT("PATH: SDL base path: %s" NL, app_base_path); DEBUGPRINT("PATH: SDL pref path: %s" NL, app_pref_path); #ifndef _WIN32 DEBUGPRINT("PATH: data directory: %s/" NL, DATADIR); #endif DEBUGPRINT("PATH: Current directory: %s" NL NL, current_directory); /* Look the very basic command line switches first */ if (argc && is_help_request_option(argv[0])) { opt = configOptions; printf("USAGE:" NL NL "\t%s -optname optval -optname2 optval2 ..." NL NL "OPTIONS:" NL NL "-config" NL "\tUse config file (or do not use the default one, if \"none\" is specified). This must be the first option if used! [default: @config]" NL, exe ); while (opt->name) { printf("-%s" NL "\t%s [default: %s]" NL, opt->name, opt->help, opt->defval ? opt->defval : "-"); opt++; } printf(NL "%s" NL, disclaimer); #ifdef _WIN32 if (!console_is_open) ERROR_WINDOW("Could not dump help, since console couldn't be allocated."); #endif XEMUEXIT(0); } DEBUGPRINT("%s" NL NL, disclaimer); if (argc && !strcasecmp(argv[0], "-testparsing")) { testparsing = 1; argc--; argv++; } if (argc & 1) { fprintf(stderr, "FATAL: Bad command line: should be even number of parameters (two for an option as key and its value)" NL); return 1; } if (argc > 1 && !strcmp(argv[0], "-config")) { default_config = 0; config_name = argv[1]; argc -= 2; argv += 2; } /* Set default (built-in) values */ opt = configOptions; while (opt->name) { if (opt->defval) config_set_internal(opt->name, -1, opt->defval); opt++; } config_set_internal("rom", 0, COMBINED_ROM_FN); // set default "combined" ROM image set (from segment 0, starting with EXOS) /* Default values for the keyboard follows ... */ keymap_preinit_config_internal(); /* check if we have written sample config file, if there is not, let's create one */ save_sample_config(DEFAULT_CONFIG_SAMPLE_FILE); /* now parse config file (not the sample one!) if there is any */ if (strcasecmp(config_name, "none")) { char path[PATH_MAX + 1]; FILE *f = open_emu_file(config_name, "r", path); DEBUGPRINT("CONFIG: config file: %s (%s)" NL, config_name, f ? path : "*** CANNOT OPEN, NOT USING CONFIG FILE ***"); if (f) { if (load_config_file_stream(f, path)) { fclose(f); return 1; } fclose(f); } else if (!default_config) { fprintf(stderr, "FATAL: Cannot open requested config file: %s" NL, config_name); return 1; } else DEBUGPRINT("CONFIG: Skipping default config file (cannot open), using built-in defaults." NL); } else DEBUGPRINT("CONFIG: Using config file: DISABLED in command line" NL); /* parse command line ... */ if (parse_command_line(argc, argv)) return -1; /* open debug file, if it was not requested via command line at the beginning ... */ if (!debug_fp && strcmp(config_getopt_str(DEBUGFILE_OPT), "none")) { debug_fp = fopen(config_getopt_str(DEBUGFILE_OPT), "w"); DEBUGPRINT("DEBUG: enable logging into file: %s" NL, config_getopt_str(DEBUGFILE_OPT)); if (!debug_fp) ERROR_WINDOW("Cannot open debug messages log file requested: %s", config_getopt_str(DEBUGFILE_OPT)); } if (debug_fp) INFO_WINDOW("DEBUG: Debug messages logging is active"); else printf("DEBUG: No debug messages logging is active." NL); /* test parsing mode? */ if (testparsing) { printf(NL "--- TEST DUMP OF *PARSED* CONFIGURATION (requested)" NL NL); dump_config(stdout); printf(NL "--- END OF TEST PARSING MODE (requested)" NL); XEMUEXIT(0); } DEBUG("CONFIG: End of configuration step." NL NL); /* Close console, unless user requested it with the -console option */ #ifdef _WIN32 if (!config_getopt_int("console")) console_close_window(); #else if (config_getopt_int("console")) console_open_window(); // on non-windows, it only will mark console as open for monitor to be used .. #endif return 0; }
static void cvm_oct_rgmii_poll(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); cvmx_helper_link_info_t link_info; link_info = cvmx_helper_link_get(priv->port); if (link_info.u64 == priv->link_info) { /* * If the 10Mbps preamble workaround is supported and we're * at 10Mbps we may need to do some special checking. */ if (USE_10MBPS_PREAMBLE_WORKAROUND && (link_info.s.speed == 10)) { /* * Read the GMXX_RXX_INT_REG[PCTERR] bit and * see if we are getting preamble errors. */ int interface = INTERFACE(priv->port); int index = INDEX(priv->port); union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg; gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, interface)); if (gmxx_rxx_int_reg.s.pcterr) { /* * We are getting preamble errors at * 10Mbps. Most likely the PHY is * giving us packets with mis aligned * preambles. In order to get these * packets we need to disable preamble * checking and do it in software. */ union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl; union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; /* Disable preamble checking */ gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface)); gmxx_rxx_frm_ctl.s.pre_chk = 0; cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface), gmxx_rxx_frm_ctl.u64); /* Disable FCS stripping */ ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); ipd_sub_port_fcs.s.port_bit &= 0xffffffffull ^ (1ull << priv->port); cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); /* Clear any error bits */ cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), gmxx_rxx_int_reg.u64); DEBUGPRINT("%s: Using 10Mbps with software preamble removal\n", dev->name); } } return; } /* If the 10Mbps preamble workaround is allowed we need to on preamble checking, FCS stripping, and clear error bits on every speed change. If errors occur during 10Mbps operation the above code will change this stuff */ if (USE_10MBPS_PREAMBLE_WORKAROUND) { union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl; union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg; int interface = INTERFACE(priv->port); int index = INDEX(priv->port); /* Enable preamble checking */ gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface)); gmxx_rxx_frm_ctl.s.pre_chk = 1; cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface), gmxx_rxx_frm_ctl.u64); /* Enable FCS stripping */ ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); ipd_sub_port_fcs.s.port_bit |= 1ull << priv->port; cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); /* Clear any error bits */ gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, interface)); cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), gmxx_rxx_int_reg.u64); } if (priv->phydev == NULL) { link_info = cvmx_helper_link_autoconf(priv->port); priv->link_info = link_info.u64; } if (priv->phydev == NULL) cvm_oct_set_carrier(priv, link_info); }
void Event::_setContext (const char* file, int line, Event::context context) { DEBUGPRINT(D_EVENT,("enter ctx=%s from %s:%d", CtxStr[context], NONULL (file), line)); contextStack->push_back (context); sigContextChange.emit (context, E_CONTEXT_ENTER); }