void RopeJoint::attachEnd(int ropeEndNumber, UnifiedHandle obj, const VC3 &localOffset) { assert(ropeEndNumber >= 0 && ropeEndNumber < ROPEJOINT_ENDS); assert(obj == UNIFIED_HANDLE_NONE || VALIDATE_UNIFIED_HANDLE_BITS(obj)); this->objHandle[ropeEndNumber] = obj; this->localOffset[ropeEndNumber] = localOffset; }
int UnitList::unifiedHandleToUnitId(UnifiedHandle unifiedHandle) const { // why bother removing the bit, no reason for that... duh. //assert(IS_UNIFIED_HANDLE_UNIT(unifiedHandle)); //return (unifiedHandle ^ UNIFIED_HANDLE_BIT_UNIT); // the correct implementation... assert(VALIDATE_UNIFIED_HANDLE_BITS(unifiedHandle)); assert(IS_UNIFIED_HANDLE_UNIT(unifiedHandle)); return unifiedHandle; }
UnifiedHandle UnitList::getUnifiedHandle(int unitId) const { // why bother removing the bit, no reason for that... duh. //assert(!IS_UNIFIED_HANDLE_UNIT(unitId)); //assert(IS_UNIFIED_HANDLE_UNIT(unitId | UNIFIED_HANDLE_BIT_UNIT)); //return (unitId | UNIFIED_HANDLE_BIT_UNIT); // the correct implementation... assert(VALIDATE_UNIFIED_HANDLE_BITS(unitId)); assert(IS_UNIFIED_HANDLE_UNIT(unitId)); return unitId; }
void SyncScripting::process(util::ScriptProcess *sp, int command, int intData, char *stringData, ScriptLastValueType *lastValue, GameScriptData *gsd, Game *game, bool *pause) { switch(command) { case GS_CMD_editSendMoveUnifiedHandleObjectToPosition: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { game->unifiedHandleManager->setObjectPosition(gsd->unifiedHandle, gsd->position); // TODO: sync to editor syncer... } } else { sp->error("SyncScripting::process - editSendMoveUnifiedHandleObjectToPosition, unified handle not valid."); } break; case GS_CMD_editSendDeleteUnifiedHandleObject: break; case GS_CMD_editSendDuplicateUnifiedHandleObject: break; case GS_CMD_editSendRotateUnifiedHandleObjectX: break; case GS_CMD_editSendRotateUnifiedHandleObjectY: break; case GS_CMD_editSendRotateUnifiedHandleObjectZ: break; /* case GS_CMD_editRecvMoveUnifiedHandleObjectToPosition: break; case GS_CMD_editRecvDeleteUnifiedHandleObject: break; case GS_CMD_editRecvDuplicateUnifiedHandleObject: break; case GS_CMD_editRecvRotateUnifiedHandleObjectX: break; case GS_CMD_editRecvRotateUnifiedHandleObjectY: break; case GS_CMD_editRecvRotateUnifiedHandleObjectZ: break; */ default: sp->error("SyncScripting::process - Unknown command."); assert(0); } }
void SelectionVisualizer::setSelectionForUnifiedHandle(UnifiedHandle uh) { if (!VALIDATE_UNIFIED_HANDLE_BITS(uh)) { LOG_WARNING_W_DEBUG("SelectionVisualizer::setSelectionForUnifiedHandle - Given unified handle is not valid.", int2str(uh)); return; } for (int i = 0; i < (int)selectionUnifiedHandles.size(); i++) { if (selectionUnifiedHandles[i] == uh) { LOG_WARNING_W_DEBUG("SelectionVisualizer::setSelectionForUnifiedHandle - Given unified handle already found in list.", int2str(uh)); return; } } selectionUnifiedHandles.push_back(uh); }
void SelectionVisualizer::clearSelectionForUnifiedHandle(UnifiedHandle uh) { if (!VALIDATE_UNIFIED_HANDLE_BITS(uh)) { LOG_WARNING_W_DEBUG("SelectionVisualizer::clearSelectionForUnifiedHandle - Given unified handle is not valid.", int2str(uh)); return; } for (int i = 0; i < (int)selectionUnifiedHandles.size(); i++) { if (selectionUnifiedHandles[i] == uh) { selectionUnifiedHandles.erase(selectionUnifiedHandles.begin() + i); return; } } LOG_WARNING_W_DEBUG("SelectionVisualizer::clearSelectionForUnifiedHandle - Given unified handle not found in list.", int2str(uh)); }
void TerrainObjectScripting::process(util::ScriptProcess *sp, int command, int intData, char *stringData, ScriptLastValueType *lastValue, GameScriptData *gsd, Game *game) { switch(command) { case GS_CMD_getTerrainObjectMetaValueString: if (stringData != NULL) { if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL && game->gameUI->getTerrain()->hasObjectTypeMetaValue(gsd->unifiedHandle, stringData)) { gsd->setStringValue(game->gameUI->getTerrain()->getObjectTypeMetaValue(gsd->unifiedHandle, stringData).c_str()); } else { sp->warning("MiscScripting::process - getTerrainObjectMetaValueString, object type does not have requested meta key."); Logger::getInstance()->debug(stringData); gsd->setStringValue(NULL); } } else { sp->error("MiscScripting::process - getTerrainObjectMetaValueString, object does not exist with given unified handle."); gsd->setStringValue(NULL); } } else { sp->error("MiscScripting::process - getTerrainObjectMetaValueString, object with given unified handle is not a terrain object."); gsd->setStringValue(NULL); } } else { sp->error("MiscScripting::process - getTerrainObjectMetaValueString, invalid unified handle."); gsd->setStringValue(NULL); } } else { sp->error("MiscScripting::process - getTerrainObjectMetaValueString parameter missing (terrain object meta key name expected)."); gsd->setStringValue(NULL); } break; case GS_CMD_hasTerrainObjectMetaValueString: if (stringData != NULL) { if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL && game->gameUI->getTerrain()->hasObjectTypeMetaValue(gsd->unifiedHandle, stringData)) { *lastValue = 1; } else { *lastValue = 0; } } else { sp->error("MiscScripting::process - hasTerrainObjectMetaValueString, object does not exist with given unified handle."); *lastValue = 0; } } else { sp->error("MiscScripting::process - hasTerrainObjectMetaValueString, object with given unified handle is not a terrain object."); *lastValue = 0; } } else { sp->error("MiscScripting::process - hasTerrainObjectMetaValueString, invalid unified handle."); *lastValue = 0; } } else { sp->error("MiscScripting::process - hasTerrainObjectMetaValueString parameter missing (terrain object meta key name expected)."); *lastValue = 0; } break; case GS_CMD_getTerrainObjectVariable: if (stringData != NULL) { if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL && game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { int varNum = game->gameUI->getTerrain()->getObjectVariableNumberByName(stringData); if (varNum != -1) { *lastValue = game->gameUI->getTerrain()->getObjectVariableValue(gsd->unifiedHandle, varNum); } else { sp->warning("MiscScripting::process - getTerrainObjectVariable, terrain object variable of given name does not exist."); Logger::getInstance()->debug(stringData); *lastValue = 0; } } else { sp->error("MiscScripting::process - getTerrainObjectVariable, object does not exist with given unified handle."); *lastValue = 0; } } else { sp->error("MiscScripting::process - getTerrainObjectVariable, object with given unified handle is not a terrain object."); *lastValue = 0; } } else { sp->error("MiscScripting::process - getTerrainObjectVariable, invalid unified handle."); *lastValue = 0; } } else { sp->error("MiscScripting::process - getTerrainObjectVariable parameter missing (terrain object variable name expected)."); *lastValue = 0; } break; case GS_CMD_setTerrainObjectVariable: if (stringData != NULL) { if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL && game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { int varNum = game->gameUI->getTerrain()->getObjectVariableNumberByName(stringData); if (varNum != -1) { game->gameUI->getTerrain()->setObjectVariableValue(gsd->unifiedHandle, varNum, *lastValue); } else { sp->warning("MiscScripting::process - setTerrainObjectVariable, terrain object variable of given name does not exist."); Logger::getInstance()->debug(stringData); } } else { sp->error("MiscScripting::process - setTerrainObjectVariable, object does not exist with given unified handle."); } } else { sp->error("MiscScripting::process - setTerrainObjectVariable, object with given unified handle is not a terrain object."); } } else { sp->error("MiscScripting::process - setTerrainObjectVariable, invalid unified handle."); } } else { sp->error("MiscScripting::process - setTerrainObjectVariable parameter missing (terrain object variable name expected)."); } break; case GS_CMD_changeTerrainObjectTo: if (stringData != NULL) { if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL && game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { int modelId = game->gameUI->getTerrain()->getModelIdForFilename(stringData); if (modelId != -1) { gsd->unifiedHandle = game->gameUI->getTerrain()->changeObjectTo(gsd->unifiedHandle, modelId); if (gsd->unifiedHandle == UNIFIED_HANDLE_NONE) { sp->error("MiscScripting::process - changeTerrainObjectTo, Terrain::changeObjectTo failed (internal error?)."); } } else { sp->error("MiscScripting::process - changeTerrainObjectTo, no terrain object model loaded with given filename."); } } else { sp->error("MiscScripting::process - changeTerrainObjectTo, object does not exist with given unified handle."); } } else { sp->error("MiscScripting::process - changeTerrainObjectTo, object with given unified handle is not a terrain object."); } } else { sp->error("MiscScripting::process - changeTerrainObjectTo, invalid unified handle."); } } else { sp->error("MiscScripting::process - changeTerrainObjectTo, parameter missing (terrain object variable name expected)."); } break; case GS_CMD_deleteTerrainObject: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL && game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { game->gameUI->getTerrain()->deleteTerrainObject(gsd->unifiedHandle); } else { sp->error("MiscScripting::process - deleteTerrainObject, object does not exist with given unified handle."); } } else { sp->error("MiscScripting::process - deleteTerrainObject, object with given unified handle is not a terrain object."); } } else { sp->error("MiscScripting::process - deleteTerrainObject, invalid unified handle."); } break; case GS_CMD_setTerrainObjectDamageTextureFadeFactorToFloatValue: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL && game->unifiedHandleManager->doesObjectExist(gsd->unifiedHandle)) { game->gameUI->getTerrain()->setInstanceDamageTexture(gsd->unifiedHandle, gsd->floatValue); } else { sp->error("MiscScripting::process - setTerrainObjectDamageTextureFadeFactor, object does not exist with given unified handle."); } } else { sp->error("MiscScripting::process - setTerrainObjectDamageTextureFadeFactor, object with given unified handle is not a terrain object."); } } else { sp->error("MiscScripting::process - setTerrainObjectDamageTextureFadeFactor, invalid unified handle."); } break; case GS_CMD_doesReplacementForTerrainObjectExist: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL) { if (!game->gameUI->getTerrain()->doesTrackableUnifiedHandleObjectExist(gsd->unifiedHandle)) { UnifiedHandle uh = game->gameUI->getTerrain()->getReplacementForUnifiedHandleObject(gsd->unifiedHandle); if (uh != UNIFIED_HANDLE_NONE) *lastValue = 1; else *lastValue = 0; } else { // sp->warning("... terrain object was not even destroyed? ..."); *lastValue = 0; } } } else { sp->error("MiscScripting::process - getReplacementForTerrainObject, object with given unified handle is not a terrain object."); *lastValue = 0; } } else { sp->error("MiscScripting::process - getReplacementForTerrainObject, invalid unified handle."); *lastValue = 0; } break; case GS_CMD_getReplacementForTerrainObject: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL) { if (!game->gameUI->getTerrain()->doesTrackableUnifiedHandleObjectExist(gsd->unifiedHandle)) { gsd->unifiedHandle = game->gameUI->getTerrain()->getReplacementForUnifiedHandleObject(gsd->unifiedHandle); } else { // sp->warning("... terrain object was not even destroyed? ..."); gsd->unifiedHandle = UNIFIED_HANDLE_NONE; } } } else { sp->error("MiscScripting::process - getReplacementForTerrainObject, object with given unified handle is not a terrain object."); gsd->unifiedHandle = UNIFIED_HANDLE_NONE; } } else { sp->error("MiscScripting::process - getReplacementForTerrainObject, invalid unified handle."); gsd->unifiedHandle = UNIFIED_HANDLE_NONE; } break; case GS_CMD_findClosestTerrainObjectOfMaterial: if (stringData != NULL) { if (game->gameUI->getTerrain() != NULL) { // NOTE: hard coded max radius value here. float maxRadius = 100.0f; gsd->unifiedHandle = game->gameUI->getTerrain()->findClosestTerrainObjectOfMaterial(gsd->position, stringData, maxRadius); if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { *lastValue = 1; } else { *lastValue = 0; } } else { *lastValue = 0; } } else { sp->error("MiscScripting::process - findClosestTerrainObjectOfMaterial parameter missing."); } break; case GS_CMD_setTerrainObjectByIdString: if (stringData != NULL) { if (game->gameUI->getTerrain() != NULL) { gsd->unifiedHandle = game->gameUI->getTerrain()->findTerrainObjectByIdString(stringData); if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { *lastValue = 1; } else { *lastValue = 0; } } else { *lastValue = 0; } } else { sp->error("MiscScripting::process - setTerrainObjectByIdString parameter missing."); } break; case GS_CMD_getTerrainObjectPosition: // NOTE: this is the same as getUnifiedHandleObjectPosition, but for terrain object only. if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL) { if (game->gameUI->getTerrain()->doesTrackableUnifiedHandleObjectExist(gsd->unifiedHandle)) { gsd->position = game->gameUI->getTerrain()->getTrackableUnifiedHandlePosition(gsd->unifiedHandle); } else { sp->error("MiscScripting::process - getTerrainObjectPosition, terrain object with given unified handle does not exist."); } } } else { sp->error("MiscScripting::process - getTerrainObjectPosition, object with given unified handle is not a terrain object."); } } else { sp->error("MiscScripting::process - getTerrainObjectPosition, invalid unified handle."); } break; case GS_CMD_getTerrainObjectIdString: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(gsd->unifiedHandle)) { if (game->gameUI->getTerrain() != NULL) { if (game->gameUI->getTerrain()->doesTrackableUnifiedHandleObjectExist(gsd->unifiedHandle)) { gsd->setStringValue(game->gameUI->getTerrain()->getTerrainObjectIdString(gsd->unifiedHandle)); } else { sp->error("MiscScripting::process - getTerrainObjectIdString, terrain object with given unified handle does not exist."); } } } else { sp->error("MiscScripting::process - getTerrainObjectIdString, object with given unified handle is not a terrain object."); } } else { sp->error("MiscScripting::process - getTerrainObjectIdString, invalid unified handle."); } break; case GS_CMD_findClosestTerrainObjectWithFilenamePart: if (stringData != NULL) { if (game->gameUI->getTerrain() != NULL) { // NOTE: hard coded max radius value here. float maxRadius = 100.0f; gsd->unifiedHandle = game->gameUI->getTerrain()->findClosestTerrainObjectWithFilenamePart(gsd->position, stringData, maxRadius); if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { *lastValue = 1; } else { *lastValue = 0; } } else { *lastValue = 0; } } else { sp->error("MiscScripting::process - findClosestTerrainObjectWithFilenamePart parameter missing."); } break; default: sp->error("MiscScripting::process - Unknown command."); assert(0); } }
void DevScripting::process(util::ScriptProcess *sp, int command, int intData, char *stringData, ScriptLastValueType *lastValue, GameScriptData *gsd, Game *game, bool *pause) { switch(command) { case GS_CMD_ERROR: //sp->error("DevScripting::process - Script error:"); Logger::getInstance()->error("DevScripting::process - Script error:"); if (stringData != NULL) { sp->error(stringData); } else { sp->error("DevScripting::process - Script error (error command has null parameter)."); } break; case GS_CMD_RELOADSCRIPTFILE: if (stringData != NULL) { util::ScriptManager::getInstance()->loadScripts(stringData, NULL, true); } else { sp->error("GameScripting::process - reloadScriptFile parameter missing."); } break; case GS_CMD_reloadParticleEffects: if (game->inCombat && game->gameUI->getVisualEffectManager() != NULL) { game->gameUI->getVisualEffectManager()->loadParticleEffects(); Logger::getInstance()->info("GameScripting::process - reloadParticleEffects, particle effects reloaded (existing effects may not be affected)."); } else { sp->warning("GameScripting::process - reloadParticleEffects called while in menus or no visual effect manager loaded (call ignored)."); } break; case GS_CMD_RELOADSTRINGVALUESCRIPTFILE: if (gsd->stringValue != NULL) { util::ScriptManager::getInstance()->loadScripts(gsd->stringValue, NULL, true); } else { sp->error("GameScripting::process - reloadStringValueScriptFile for null string."); } break; case GS_CMD_SCRIPTDUMP: { Logger::getInstance()->debug("Script dump command encountered, output follows..."); char *dump = sp->getScript()->getDebugDump(sp, false); if (dump != NULL) { Logger::getInstance()->debug(dump); delete [] dump; } else { Logger::getInstance()->debug("Null output."); assert(0); } } break; case GS_CMD_FULLSCRIPTDUMP: { Logger::getInstance()->debug("Full script dump command encountered, output follows..."); char *dump = sp->getScript()->getDebugDump(sp, true); if (dump != NULL) { Logger::getInstance()->debug(dump); delete [] dump; } else { Logger::getInstance()->debug("Null output."); assert(0); } } break; case GS_CMD_DEVUNITSCRIPTDUMP: { Logger::getInstance()->debug("Dev unit script dump command encountered, output follows..."); // WARNING: unsafe cast! util::ScriptProcess *mainsp = ((game::UnitLevelAI *)game->devUnit->getAI())->mainScriptProcess; char *dump = mainsp->getScript()->getDebugDump(mainsp, false); if (dump != NULL) { Logger::getInstance()->debug(dump); delete [] dump; } else { Logger::getInstance()->debug("Null output."); assert(0); } } break; case GS_CMD_DEVUNITFULLSCRIPTDUMP: { if (game->devUnit != NULL) { Logger::getInstance()->debug("Dev unit full script dump command encountered, output follows..."); // WARNING: unsafe cast! util::ScriptProcess *mainsp = ((game::UnitLevelAI *)game->devUnit->getAI())->mainScriptProcess; char *dump = mainsp->getScript()->getDebugDump(mainsp, true); if (dump != NULL) { Logger::getInstance()->debug(dump); delete [] dump; } else { Logger::getInstance()->debug("Null output."); assert(0); } } } break; case GS_CMD_DEVMESSAGE: if (stringData != NULL) { if (SimpleOptions::getBool(DH_OPT_B_SCRIPT_DEV_MODE)) { if (game->devUnit == NULL || gsd->unit == game->devUnit) { sp->warning(stringData); } } } break; case GS_CMD_HIDECONSOLE: game->gameUI->hideConsole(); break; case GS_CMD_SHOWCONSOLE: game->gameUI->showConsole(); break; case GS_CMD_DEVSIDESWAP: if (intData >= 0 && intData < ABS_MAX_PLAYERS) { if (SimpleOptions::getBool(DH_OPT_B_ALLOW_SIDE_SWAP) && game->inCombat) { sp->debug("DevScripting::process - Swapping sides."); game->unitSelections[game->singlePlayerNumber]->selectAllUnits(false); game->gameUI->closeCombatWindow(game->singlePlayerNumber); game->singlePlayerNumber = intData; game->gameUI->openCombatWindow(game->singlePlayerNumber); } } else { sp->warning("DevScripting::process - devSideSwap parameter bad."); } break; case GS_CMD_DEVSIDESWAPTOVALUE: if (*lastValue >= 0 && *lastValue < ABS_MAX_PLAYERS) { if (SimpleOptions::getBool(DH_OPT_B_ALLOW_SIDE_SWAP) && game->inCombat) { sp->debug("DevScripting::process - Swapping sides."); game->gameUI->closeCombatWindow(game->singlePlayerNumber); game->singlePlayerNumber = *lastValue; game->gameUI->openCombatWindow(game->singlePlayerNumber); } } else { sp->warning("DevScripting::process - devSideSwapToValue last value out of ranged."); } break; case GS_CMD_DEVUNIT: if (gsd->unit == NULL) { sp->warning("DevScripting::process - devUnit for null unit."); game->devUnit = NULL; } else { game->devUnit = gsd->unit; } break; case GS_CMD_CLEARDEVUNIT: game->devUnit = NULL; break; case GS_CMD_DUMPSTATUSINFO: if (game->getGameScene() != NULL && game->inCombat) { char *stats = game->getGameScene()->getStorm3D()->GetPrintableStatusInfo(); Logger::getInstance()->info(stats); game->getGameScene()->getStorm3D()->DeletePrintableStatusInfo(stats); Logger::getInstance()->info("Visual effects running:"); Logger::getInstance()->info(int2str(ui::visual_effect_allocations)); } else { Logger::getInstance()->warning("DevScripting::process - dumpStatusInfo cannot get info for null scene."); } break; case GS_CMD_dumpEffectsInfo: if (game->getGameScene() != NULL && game->inCombat) { Logger::getInstance()->info("Visual effects running:"); Logger::getInstance()->info(int2str(ui::visual_effect_allocations)); Logger::getInstance()->info("Particle spawners total amount:"); Logger::getInstance()->info(int2str(game->particleSpawnerManager->getParticleSpawnerAmount())); } else { Logger::getInstance()->warning("DevScripting::process - dumpEffectsInfo cannot get info for null scene."); } break; case GS_CMD_dumpGameSceneGraph: { char *stats = game->getGameSceneGraphDump(); Logger::getInstance()->info(stats); game->deleteGameSceneGraphDump(stats); } break; case GS_CMD_dumpPhysicsInfo: { char *stats = UnitPhysicsUpdater::getStatusInfo(); Logger::getInstance()->info(stats); UnitPhysicsUpdater::deleteStatusInfo(stats); #ifdef PHYSICS_ODE stats = PhysicsActorOde::getStatusInfo(); Logger::getInstance()->info(stats); PhysicsActorOde::deleteStatusInfo(stats); #endif #ifdef PHYSICS_PHYSX if(game->getGamePhysics() && game->getGamePhysics()->getPhysicsLib()) { std::string info = game->getGamePhysics()->getPhysicsLib()->getStatistics(); Logger::getInstance()->info(info.c_str()); } #endif } break; case GS_CMD_RAYTRACEBLAST: if (game->getGameScene() != NULL && game->inCombat) { if (game->gameUI->getFirstPerson(0) != 0) { if (game->gameUI->getFirstPerson(0)->getVisualObject() != NULL) { game->gameUI->getFirstPerson(0)->getVisualObject()->setCollidable(false); } VC3 pos = game->gameUI->getFirstPerson(0)->getPosition(); pos.y += 1.0f; for (float b = -2.0f; b < 1.0f; b += 0.5f) { for (float a = 0; a < 2*3.1415f; a += 0.25f) { VC3 dir = VC3(cosf(a), sinf(b / 2.0f), sinf(a)); dir.Normalize(); GameCollisionInfo cinfo; game->getGameScene()->rayTrace(pos, dir, 20, cinfo, true, false); } } if (game->gameUI->getFirstPerson(0)->getVisualObject() != NULL) { game->gameUI->getFirstPerson(0)->getVisualObject()->setCollidable(true); } } } break; case GS_CMD_DEVEXIT: sp->error("DevScripting::process - devExit called, making an immediate and unclean exit."); exit(0); break; case GS_CMD_DEVASSERT: if (*lastValue == 0) { sp->warning("DevScripting::process - devAssert."); FB_ASSERT(!"DevScripting::process - devAssert."); } break; case GS_CMD_DEVCRASH: { #ifndef FB_TESTBUILD sp->warning("DevScripting::process - devCrash ignored."); #else sp->warning("DevScripting::process - devCrash about to crash."); FB_ASSERT(!"DevScripting::process - devCrash."); int *crashPtr = NULL; int crashValue = *crashPtr; *lastValue = crashValue; #endif } break; case GS_CMD_LISTGLOBALVARIABLES: { LinkedList *tmp = util::Script::getGlobalVariableList(false); while (!tmp->isEmpty()) { const char *varname = (const char *)tmp->popLast(); int varval = 0; util::Script::getGlobalIntVariableValue(varname, &varval); char *tmpbuf = new char[strlen(varname) + 32]; strcpy(tmpbuf, varname); strcat(tmpbuf, " ("); strcat(tmpbuf, int2str(varval)); strcat(tmpbuf, ")"); Logger::getInstance()->info(tmpbuf); } delete tmp; } break; case GS_CMD_reloadObjectDurabilities: if (gameui_physicsDamageManager != NULL) { gameui_physicsDamageManager->reloadConfiguration(); } break; case GS_CMD_openScoreWindow: { if( game && game->gameUI ) { game->gameUI->openScoreWindow( game->singlePlayerNumber ); } } break; case GS_CMD_openMissionSelectionWindow: { if( game && game->gameUI ) { game->gameUI->openMissionSelectionWindow(); } } break; case GS_CMD_dumpScriptInfo: Logger::getInstance()->info(util::ScriptManager::getInstance()->getStatusInfo().c_str()); Logger::getInstance()->info("Custom script processes amount:"); Logger::getInstance()->info(int2str(game->getCustomScriptProcessAmount())); break; case GS_CMD_devStopAllCustomScripts: game->stopAllCustomScriptProcesses(); break; #ifndef PROJECT_SHADOWGROUNDS case GS_CMD_missionSelectionWindowAddMissionButton: { if( game && game->gameUI && game->gameUI->getMissionSelectionWindow() ) { game->gameUI->getMissionSelectionWindow()->AddMissionButton( stringData ); } } break; #endif case GS_CMD_openMainMenuWindow: { if( game && game->gameUI ) { game->gameUI->openMainmenuFromGame( intData ); // game->gameUI->getCommandWindow( game->singlePlayerNumber )->openMenu( intData ); } } break; case GS_CMD_devRunSingleCommand: if (stringData != NULL) { int slen = strlen(stringData); char *cmdName = new char[slen + 1]; char *param = new char[slen + 1]; int cmdNamePos = 0; int paramPos = 0; cmdName[0] = '\0'; param[0] = '\0'; bool trimming = true; bool readingCmd = false; bool skippingSep = false; bool readingParam = false; for (int i = 0; i < slen; i++) { if (trimming) { if (stringData[i] != ' ' && stringData[i] != '\t') { trimming = false; readingCmd = true; } } if (readingCmd) { if (stringData[i] == ' ' || stringData[i] == '\t') { readingCmd = false; skippingSep = true; } else { cmdName[cmdNamePos] = stringData[i]; cmdNamePos++; } } if (skippingSep) { if (stringData[i] != ' ' && stringData[i] != '\t') { skippingSep = false; readingParam = true; } } if (readingParam) { param[paramPos] = stringData[i]; paramPos++; } } cmdName[cmdNamePos] = '\0'; param[paramPos] = '\0'; if (cmdName[0] == '\0') { sp->error("DevScripting::process - devRunSingleCommand parameter invalid."); } else { int tmpInt = *lastValue; int tmpInt2 = sp->getSecondaryValue(); bool success; if (!readingParam) { success = game->gameScripting->runSingleSimpleStringCommand(cmdName, NULL, &tmpInt, &tmpInt2); } else { success = game->gameScripting->runSingleSimpleStringCommand(cmdName, param, &tmpInt, &tmpInt2); } if (!success) { sp->error("DevScripting::process - devRunSingleCommand failed."); } *lastValue = tmpInt; sp->setSecondaryValue(tmpInt2); } delete [] param; delete [] cmdName; } else { sp->error("DevScripting::process - devRunSingleCommand parameter missing."); } break; case GS_CMD_forceCursorVisibility: { game->gameUI->forceCursorVisibility(intData == 0 ? false : true); } break; case GS_CMD_dumpMemoryInfo: { #ifdef FROZENBYTE_DEBUG_MEMORY frozenbyte::debug::dumpLeakSnapshot(); frozenbyte::debug::markLeakSnapshot(); #endif } break; case GS_CMD_devPhysicsConnectToRemoteDebugger: #ifndef FINAL_RELEASE_BUILD if (stringData != NULL) { game->getGamePhysics()->getPhysicsLib()->connectToRemoteDebugger(stringData, 5425); } else { sp->error("DevScripting::process - devPhysicsConnectToRemoteDebugger parameter missing."); } #else sp->error("DevScripting::process - devPhysicsConnectToRemoteDebugger not in build."); #endif break; case GS_CMD_clearSelectionVisualizationForUnifiedHandle: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { SelectionVisualizer::clearSelectionForUnifiedHandle(gsd->unifiedHandle); } else { sp->error("DevScripting::process - clearSelectionVisualizationForUnifiedHandle, unified handle not valid."); } break; case GS_CMD_setSelectionVisualizationForUnifiedHandle: if (VALIDATE_UNIFIED_HANDLE_BITS(gsd->unifiedHandle)) { SelectionVisualizer::setSelectionForUnifiedHandle(gsd->unifiedHandle); } else { sp->error("DevScripting::process - clearSelectionVisualizationForUnifiedHandle, unified handle not valid."); } break; case GS_CMD_reloadChangedScriptFiles: { int reloaded = util::ScriptManager::getInstance()->reloadChangedScripts(); if (reloaded > 0) { std::string tmp = "reloadChangedScriptFiles - Reloaded "; tmp += int2str(reloaded); tmp += " script(s)."; Logger::getInstance()->info(tmp.c_str()); } else { Logger::getInstance()->info("reloadChangedScriptFiles - No scripts were reloaded."); } } break; case GS_CMD_restartApplicationSoft: #ifdef PROJECT_AOV Logger::getInstance()->info("DevScripting::process - restartApplicationSoft called."); game->gameUI->setQuitRequested(); ::app_soft_restart_requested = true; #else Logger::getInstance()->warning("DevScripting::process - restartApplicationSoft not in build."); #endif break; case GS_CMD_restartApplicationHard: #ifdef PROJECT_AOV Logger::getInstance()->info("DevScripting::process - restartApplicationHard called."); game->gameUI->setQuitRequested(); ::app_hard_restart_requested = true; #else Logger::getInstance()->warning("DevScripting::process - restartApplicationHard not in build."); #endif break; default: sp->error("DevScripting::process - Unknown command."); assert(0); } }
void DebugTerrainObjectVisualizer::visualizeTerrainObject(game::Game *game, UnifiedHandle terrainObject, const VC3 &cameraPosition, DebugTerrainObjectVisFlags visFlags) { char textbuf[128]; assert(VALIDATE_UNIFIED_HANDLE_BITS(terrainObject)); if (!game->unifiedHandleManager->doesObjectExist(terrainObject)) { return; } VC3 cullpos = game->unifiedHandleManager->getObjectPosition(terrainObject); VC3 distToCamVec = cullpos - cameraPosition; // 2D RANGE distToCamVec.y = 0; float distToCamSq = distToCamVec.GetSquareLength(); if (distToCamSq < (DEBUGTERRAINOBJECTVISUALIZER_MAX_DIST * DEBUGTERRAINOBJECTVISUALIZER_MAX_DIST)) { // ok } else { return; } std::string fname = game->gameUI->getTerrain()->getTypeFilenameByUnifiedHandle(terrainObject); std::string fnamecut; for (int i = (int)fname.length() - 1; i >= 0; i--) { if (fname[i] == '\\') { fname[i] = '/'; } if (fname[i] == '/') { if (fnamecut.empty()) { fnamecut = fname.substr(i + 1, fname.length() - (i + 1)); } } } const char *totypename = game::SimpleOptions::getString(DH_OPT_S_DEBUG_VISUALIZE_TERRAINOBJECTS_OF_NAME); if (totypename != NULL && totypename[0] != '\0') { if (strstr(fname.c_str(), totypename) != NULL) { // ok } else { return; } } COL col = COL(0.5f,0.5f,1.0f); if (visFlags & DEBUGTERRAINOBJECTVISUALIZER_FLAG_SELECTED) { // ok with that color? } else { col.r = col.r / 2.0f; col.g = col.g / 2.0f; col.b = col.b / 2.0f; } /* VC3 pos = game->unifiedHandleManager->getObjectPosition(terrainObject); pos.y += 0.03f; VC3 sizes = VC3(1.00f, 1.00f, 1.00f); VC3 c1 = VC3(pos.x - sizes.x, pos.y + sizes.y, pos.z - sizes.z); VC3 c2 = VC3(pos.x + sizes.x, pos.y + sizes.y, pos.z - sizes.z); VC3 c3 = VC3(pos.x + sizes.x, pos.y + sizes.y, pos.z + sizes.z); VC3 c4 = VC3(pos.x - sizes.x, pos.y + sizes.y, pos.z + sizes.z); VC3 cb1 = VC3(pos.x - sizes.x, pos.y - sizes.y, pos.z - sizes.z); VC3 cb2 = VC3(pos.x + sizes.x, pos.y - sizes.y, pos.z - sizes.z); VC3 cb3 = VC3(pos.x + sizes.x, pos.y - sizes.y, pos.z + sizes.z); VC3 cb4 = VC3(pos.x - sizes.x, pos.y - sizes.y, pos.z + sizes.z); */ OOBB oobb = game->gameUI->getTerrain()->getOOBB(terrainObject); VC3 pos = oobb.center; VC3 c1 = pos - (oobb.axes[0] * oobb.extents.x) + (oobb.axes[1] * oobb.extents.y) - (oobb.axes[2] * oobb.extents.z); VC3 c2 = pos + (oobb.axes[0] * oobb.extents.x) + (oobb.axes[1] * oobb.extents.y) - (oobb.axes[2] * oobb.extents.z); VC3 c3 = pos + (oobb.axes[0] * oobb.extents.x) + (oobb.axes[1] * oobb.extents.y) + (oobb.axes[2] * oobb.extents.z); VC3 c4 = pos - (oobb.axes[0] * oobb.extents.x) + (oobb.axes[1] * oobb.extents.y) + (oobb.axes[2] * oobb.extents.z); VC3 cb1 = pos - (oobb.axes[0] * oobb.extents.x) - (oobb.axes[1] * oobb.extents.y) - (oobb.axes[2] * oobb.extents.z); VC3 cb2 = pos + (oobb.axes[0] * oobb.extents.x) - (oobb.axes[1] * oobb.extents.y) - (oobb.axes[2] * oobb.extents.z); VC3 cb3 = pos + (oobb.axes[0] * oobb.extents.x) - (oobb.axes[1] * oobb.extents.y) + (oobb.axes[2] * oobb.extents.z); VC3 cb4 = pos - (oobb.axes[0] * oobb.extents.x) - (oobb.axes[1] * oobb.extents.y) + (oobb.axes[2] * oobb.extents.z); /* VC3 pos = game->unifiedHandleManager->getObjectPosition(terrainObject); OOBB oobb = game->gameUI->getTerrain()->getOOBB(terrainObject); pos = oobb.center; VC3 sizes = oobb.extents; VC3 c1 = VC3(pos.x - sizes.x, pos.y + sizes.y, pos.z - sizes.z); VC3 c2 = VC3(pos.x + sizes.x, pos.y + sizes.y, pos.z - sizes.z); VC3 c3 = VC3(pos.x + sizes.x, pos.y + sizes.y, pos.z + sizes.z); VC3 c4 = VC3(pos.x - sizes.x, pos.y + sizes.y, pos.z + sizes.z); VC3 cb1 = VC3(pos.x - sizes.x, pos.y - sizes.y, pos.z - sizes.z); VC3 cb2 = VC3(pos.x + sizes.x, pos.y - sizes.y, pos.z - sizes.z); VC3 cb3 = VC3(pos.x + sizes.x, pos.y - sizes.y, pos.z + sizes.z); VC3 cb4 = VC3(pos.x - sizes.x, pos.y - sizes.y, pos.z + sizes.z); */ disposable_scene->AddLine(c1, c2, col); disposable_scene->AddLine(c2, c3, col); disposable_scene->AddLine(c3, c4, col); disposable_scene->AddLine(c4, c1, col); disposable_scene->AddLine(cb1, cb2, col); disposable_scene->AddLine(cb2, cb3, col); disposable_scene->AddLine(cb3, cb4, col); disposable_scene->AddLine(cb4, cb1, col); disposable_scene->AddLine(c1, cb1, col); disposable_scene->AddLine(c2, cb2, col); disposable_scene->AddLine(c3, cb3, col); disposable_scene->AddLine(c4, cb4, col); disposable_scene->AddLine(c4, cb4, col); int textoffy = 0; if (game::SimpleOptions::getBool(DH_OPT_B_DEBUG_VISUALIZE_TERRAINOBJECTS_EXTENDED) && distToCamSq < (DEBUGTERRAINOBJECTVISUALIZER_EXTENDED_MAX_DIST * DEBUGTERRAINOBJECTVISUALIZER_EXTENDED_MAX_DIST)) { sprintf(textbuf, "uh: %d", terrainObject); DebugVisualizerTextUtil::renderText(pos, 0, textoffy, textbuf); textoffy += 16; sprintf(textbuf, "filename: %s", fnamecut.c_str()); DebugVisualizerTextUtil::renderText(pos, 0, textoffy, textbuf); textoffy += 16; } }