/** * Resets all the class data. */ void TemplateDefinitionFile::cleanup(void) { m_highestVersion = 0; m_templateId.tag = NO_TAG; m_templateId.tagString = NO_TAG_STRING; m_templateLocation = LOC_NONE; IGNORE_RETURN(m_templateName.erase()); IGNORE_RETURN(m_baseName.erase()); IGNORE_RETURN(m_templateNameFilter.erase()); m_path.clear(); m_compilerPath.clear(); m_fileComments.clear(); if (m_baseDefinitionFile != NULL) { delete m_baseDefinitionFile; m_baseDefinitionFile = NULL; } std::map<int, TemplateData *>::iterator iter; for (iter = m_templateMap.begin(); iter != m_templateMap.end(); ++iter) { delete (*iter).second; (*iter).second = NULL; } m_templateMap.clear(); if (m_filterCompiledRegex != NULL) { RegexServices::freeMemory(m_filterCompiledRegex); m_filterCompiledRegex = NULL; } } // TemplateDefinitionFile::cleanup
/** * Special function used by datalint. Checks for duplicate values in base and derived templates. */ void ServerIntangibleObjectTemplate::_SimpleIngredient::testValues(void) const { IGNORE_RETURN(getName(true)); IGNORE_RETURN(getIngredient(true)); IGNORE_RETURN(getCountMin(true)); IGNORE_RETURN(getCountMax(true)); } // ServerIntangibleObjectTemplate::_SimpleIngredient::testValues
/** * Special function used by datalint. Checks for duplicate values in base and derived templates. */ void ServerIntangibleObjectTemplate::_Ingredient::testValues(void) const { IGNORE_RETURN(getIngredientType(true)); IGNORE_RETURN(getComplexityMin(true)); IGNORE_RETURN(getComplexityMax(true)); IGNORE_RETURN(getSkillCommand(true)); } // ServerIntangibleObjectTemplate::_Ingredient::testValues
/** * Special function used by datalint. Checks for duplicate values in base and derived templates. */ void ServerBuildingObjectTemplate::testValues(void) const { IGNORE_RETURN(getMaintenanceCostMin(true)); IGNORE_RETURN(getMaintenanceCostMax(true)); IGNORE_RETURN(getIsPublic(true)); ServerTangibleObjectTemplate::testValues(); } // ServerBuildingObjectTemplate::testValues
void JNICALL ScriptMethodsChatNamespace::chatSendQuestSystemMessage(JNIEnv * /*env*/, jobject /*self*/, jlong jobject_networkId, jstring jstring_message, jstring jstring_oob) { ServerObject const * serverObject = 0; { if (!JavaLibrary::getObject(jobject_networkId, serverObject)) { //@TODO: this function should not be used with object ids of players that are not on the server, however right // now we have no other method. when we have a method that reliably sends these messages across server, use it and put this back in //JAVA_THROW_SCRIPT_EXCEPTION(true, ("WARNING: ScriptMethodsChat JavaLibrary::chatSendQuestSystemMessage: could not convert parameter 1 to a valid networkId\n")); //printJavaStack(); return; } } Unicode::String message; { JavaStringParam const jt(jstring_message); IGNORE_RETURN(JavaLibrary::convert(jt, message)); } Unicode::String oob; { JavaStringParam const jt(jstring_oob); IGNORE_RETURN(!JavaLibrary::convert(jt, oob)); } JAVA_THROW_SCRIPT_EXCEPTION(message.empty() && oob.empty(), ("ScriptMethodsChat JavaLibrary::chatSendQuestSystemMessage: all parameters were valid, but empty")); Chat::sendQuestSystemMessage(*serverObject, message, oob); }
/** * Special function used by datalint. Checks for duplicate values in base and derived templates. */ void ServerManufactureSchematicObjectTemplate::testValues(void) const { IGNORE_RETURN(getDraftSchematic(true)); IGNORE_RETURN(getCreator(true)); IGNORE_RETURN(getItemCountMin(true)); IGNORE_RETURN(getItemCountMax(true)); ServerIntangibleObjectTemplate::testValues(); } // ServerManufactureSchematicObjectTemplate::testValues
/** * Special function used by datalint. Checks for duplicate values in base and derived templates. */ void SharedShipObjectTemplate::testValues(void) const { IGNORE_RETURN(getCockpitFilename(true)); IGNORE_RETURN(getHasWings(true)); IGNORE_RETURN(getPlayerControlled(true)); IGNORE_RETURN(getInteriorLayoutFileName(true)); SharedTangibleObjectTemplate::testValues(); } // SharedShipObjectTemplate::testValues
void MarketAuctionsBufferCreate::removeMarketAuctions(const NetworkId &itemId) { DEBUG_REPORT_LOG(true, ("MarketAuctionsBufferCreate Removing Market Auctions Buffer Row. rowcount:%d\n", m_rows.size())); DBSchema::MarketAuctionsRow *row=findRowByIndex(itemId); if (row) { delete row; IGNORE_RETURN(m_rows.erase(itemId)); IGNORE_RETURN(m_attributes.erase(itemId)); DEBUG_REPORT_LOG(true, ("MarketAuctionsBufferCreate Removing Market Auctions Buffer Row. rowcount:%d\n", m_rows.size())); } }
void DataTableColumnType::createDefaultCell() { std::string value; IS_NULL(m_defaultCell); // If mangleValue does not update the input value string, // then the default cell will have a value of 0 for floats and ints // and a value of empty string for strings. IGNORE_RETURN(mangleValue(value)); switch(m_basicType) { case DT_Int: m_defaultCell = new DataTableCell(static_cast<int>(strtol(value.c_str(), NULL, 0))); break; case DT_Float: m_defaultCell = new DataTableCell(static_cast<float>(atof(value.c_str()))); break; case DT_String: case DT_Comment: case DT_Unknown: default: m_defaultCell = new DataTableCell(value.c_str()); break; } }
void CustomerServiceConnection::addClient(Client * newClient) { if (clients.find(newClient) == clients.end()) IGNORE_RETURN( clients.insert(newClient) ); else DEBUG_WARNING(true, ("called CustomerServiceConnection::addClient with a client that already exists in the map.")); }
Vector ClosestPointCylinder ( Vector const & V, Cylinder const & C ) { Vector delta = V - C.getBase(); delta.y = 0.0f; real dist = delta.magnitude(); Vector point = V; // clamp the x-z coords of the point so they're inside the tube IGNORE_RETURN( delta.normalize() ); delta *= std::min( C.getRadius(), dist ); point = C.getBase() + delta; // and clamp the y coord so it's inside also real min = C.getBase().y; real max = min + C.getHeight(); point.y = clamp( min, V.y, max ); return point; }
void PvpInternal::handleAuthorityAcquire(TangibleObject &dest) { setPermFactionEnemyFlags(dest); if (hasAnyTimedEnemyFlag(dest)) IGNORE_RETURN(s_objectsWithTempFlags.insert(dest.getNetworkId())); }
/** * Initialize the ScriptFuncHashMap */ void Scripting::InitScriptFuncHashMap(void) { Scripting::ScriptFuncHashMap = new Scripting::_ScriptFuncHashMap(NUM_SCRIPT_FUNCTIONS); for (int i = 0; i < NUM_SCRIPT_FUNCTIONS; ++i) IGNORE_RETURN(Scripting::ScriptFuncHashMap->insert(std::make_pair(static_cast<int>(ScriptFuncList[i].id), &ScriptFuncList[i]))); } // InitScriptFuncHashMap
/** * Obtain the first renderable chunk which contains the specified position */ TerrainQuadTree::Node * TerrainQuadTree::Node::findFirstRenderableNode (const int ax, const int az) { TerrainQuadTree::Iterator iter (this); TerrainQuadTree::Node * node = 0; while ((node = iter.getCurNode ()) != 0) { if (node->isSelectedForRender ()) { if (node->nodeEncloses (ax, az)) return node; else return 0; } // TODO: no need to descend into all 4 quadrants... 1 is enough // descend front-to-back IGNORE_RETURN (iter.descendOneChild (node->getQuadrant (ax, az))); } return 0; }
/* dispatch loop */ void dispatchLoop(void) { SaAisErrorT rc = SA_AIS_OK; SaSelectionObjectT amf_dispatch_fd; int maxFd; fd_set read_fds; /* * Get the AMF dispatch FD for the callbacks */ if ( (rc = saAmfSelectionObjectGet(amfHandle, &amf_dispatch_fd)) != SA_AIS_OK) errorExit(rc); maxFd = amf_dispatch_fd; /* maxFd = max(amf_dispatch_fd,ckpt_dispatch_fd); */ do { FD_ZERO(&read_fds); FD_SET(amf_dispatch_fd, &read_fds); if( select(maxFd + 1, &read_fds, NULL, NULL, NULL) < 0) { char errorStr[80]; int err = errno; if (EINTR == err) continue; errorStr[0] = 0; /* just in case strerror does not fill it in */ IGNORE_RETURN(strerror_r(err, errorStr, 79)); break; } if (FD_ISSET(amf_dispatch_fd,&read_fds)) saAmfDispatch(amfHandle, SA_DISPATCH_ALL); }while(!unblockNow); }
float TrackingDynamics::alter(float elapsedTime) { Object *const ownerObject = getOwner(); if (ownerObject) { Object const *const targetObject = m_targetWatcher.getPointer(); if (targetObject) { //-- Get world position of owner and target. Vector const ownerPosition_w = ownerObject->getPosition_w(); Vector const targetPosition_w = targetObject->getPosition_w(); //-- Compute world-space direction vector. Vector direction_w = targetPosition_w - ownerPosition_w; IGNORE_RETURN(direction_w.normalize()); //-- Set current velocity. setCurrentVelocity_w(direction_w * m_speed); } //-- Handle object rotation. ownerObject->yaw_o (m_radiansPerSecond.y * elapsedTime); ownerObject->pitch_o (m_radiansPerSecond.x * elapsedTime); ownerObject->roll_o (m_radiansPerSecond.z * elapsedTime); } //-- Chain up alter. This will handle the object translation. return SimpleDynamics::alter(elapsedTime); }
void Triangle3d::calcNormal ( void ) { Vector temp = getEdgeDir0().cross( getEdgeDir1() ); IGNORE_RETURN( temp.normalize() ); m_normal = temp; }
TerrainQuadTree::~TerrainQuadTree () { IGNORE_RETURN (m_nodes->removeSubNodes (true)); delete m_nodes; m_nodes = 0; Node::remove (); }
void AiShipBehaviorTrack::alter(float deltaSeconds) { PROFILER_AUTO_BLOCK_DEFINE("AiShipBehaviorTrack::alter"); if (m_target != NULL) { IGNORE_RETURN(m_aiShipController.face(m_target->getPosition_w(), deltaSeconds)); } }
/** * Event Handling Function. * * Handles the event at current state. Handles message at the current * state. If the message/event is not handled at current state, then * its passed to the parent and passed till 'top'. If its not * handled, till top, then this method returns ERROR. else, the * transition is handled. Transition, involves all exit method from * bottom till LCA and execution of transition object function, and * entry methods from LCA till the next state. * * @param smThis Instance Object * @param msg Event that needs to be handled * * @returns * CL_OK on CL_OK (successful transition) <br/> * CL_SM_RC(CL_ERR_NULL_POINTER) on invalid/null instance/msg handle <br/> * SM_ERR_EXIT_FAILED if the exit handler returned failure * CL_SM_RC(CL_ERR_INVALID_STATE) unable to handle event at current state * */ ClRcT clHsmInstanceOnEvent(ClSmInstancePtrT smThis, ClSmEventPtrT msg ) { ClSmStatePtrT curr; ClSmTransitionPtrT tO=0; ClRcT ret = CL_OK; CL_FUNC_ENTER(); CL_ASSERT(smThis); CL_ASSERT(msg); if(!smThis || !smThis->sm || !smThis->current || !msg) { ret = CL_SM_RC(CL_ERR_NULL_POINTER); CL_FUNC_EXIT(); return ret; } for(curr=smThis->current;curr && !tO;) { /* check if the event is in event handler table */ if(msg->eventId < (ClSmEventIdT)curr->maxEventTransitions && msg->eventId >= 0) { tO = curr->eventTransitionTable[msg->eventId].transition; break; } curr=curr->parent; } if(curr && tO) { #ifdef DEBUG clLogTrace(HSM_LOG_AREA,HSM_LOG_CTX_EVENT,"StateMachine [%s] OnEvent [%d] in State [%d:%s]", smThis->name, msg->eventId, curr->type, curr->name); #else clLogTrace(HSM_LOG_AREA,HSM_LOG_CTX_EVENT,"OnEvent %d in state %d", msg->eventId, curr->type); #endif IGNORE_RETURN(_transition(smThis, tO, smThis->current, tO->nextState, msg)); } else { ret = CL_SM_RC(CL_ERR_INVALID_STATE); } CL_FUNC_EXIT(); return ret; }
/** * pruneTree removes all subtrees which do not contain any chunks. All subtree nodes are deleted. */ void TerrainQuadTree::Node::pruneTree () { if (m_numberOfChunks == 0) { IGNORE_RETURN (removeSubNodes (false)); return; } for (int i = 0; i < 4; ++i) { if (m_subNodes[i]) { if (m_subNodes[i]->m_numberOfChunks == 0) IGNORE_RETURN (m_subNodes[i]->removeSubNodes (false)); else m_subNodes[i]->pruneTree (); } } }
Vector ClosestPointSphere ( Vector const & V, Sphere const & S ) { Vector delta = V - S.getCenter(); IGNORE_RETURN( delta.normalize() ); delta *= S.getRadius(); Vector point = S.getCenter() + delta; return point; }
real DistanceLineLine ( Line3d const & A, Line3d const & B ) { Vector D = B.getPoint() - A.getPoint(); Vector N = A.getNormal().cross(B.getNormal()); IGNORE_RETURN( N.normalize() ); float dist = static_cast<float>(fabs( D.dot(N) )); return dist; }
void install () { if (s_installed) return; s_installed = true; for (int i = 0; i < static_cast<int>(ShipChassisSlotType::SCST_num_types); ++i) { IGNORE_RETURN (s_slotNameTypeMap.insert (std::make_pair (s_slotTypeNames [i], static_cast<ShipChassisSlotType::Type>(i)))); s_slotTypeShortNames [i] = StringId("space/scst_short_n", s_slotTypeNames [i]).localize(); } }
bool SurveySystem::TaskSurvey::run() { Client const * client = GameServer::getInstance().getClient(m_playerId); ResourceTypeObject const * typeObj = ServerUniverse::getInstance().getResourceTypeByName(*m_resourceTypeName); ResourceClassObject const * parentClass = ServerUniverse::getInstance().getResourceClassByName(*m_parentResourceClassName); ResourcePoolObject const * pool = typeObj ? typeObj->getPoolForCurrentPlanet() : NULL; int distBetweenPoints = m_surveyRange / (m_numPoints - 1); // -1 is so that we get points at both ends int radius = m_surveyRange / 2; if (client && typeObj && parentClass && pool && (typeObj->isDerivedFrom(*parentClass))) { std::vector<SurveyMessage::DataItem> surveyData; SurveyMessage::DataItem item; //vectors to store the data that goes to the script trigger std::vector<float> xVals; std::vector<float> zVals; std::vector<float> efficiencyVals; for (item.m_location.x=m_location.x-radius; item.m_location.x<=m_location.x+radius; item.m_location.x+=distBetweenPoints) for (item.m_location.z=m_location.z-radius; item.m_location.z<=m_location.z+radius; item.m_location.z+=distBetweenPoints) { item.m_efficiency = pool->getEfficiencyAtLocation(item.m_location.x, item.m_location.z); surveyData.push_back(item); DEBUG_REPORT_LOG(true,("Adding data item (%f,%f,%f) -- %f\n",item.m_location.x, item.m_location.y, item.m_location.z, item.m_efficiency)); xVals.push_back(item.m_location.x); zVals.push_back(item.m_location.z); efficiencyVals.push_back(item.m_efficiency); } //send the client the response data SurveyMessage msg(surveyData); client->send(msg,true); //send the data to script trigger ScriptParams params; params.addParam(xVals); params.addParam(zVals); params.addParam(efficiencyVals); ServerObject* so = ServerWorld::findObjectByNetworkId(m_playerId); if (so) IGNORE_RETURN(so->getScriptObject()->trigAllScripts(Scripting::TRIG_SURVEY_DATA_RECEIVED, params)); } else { // TODO: Survey is not valid -- what to do? } return true; }
Sphere EncloseSphere ( Sphere const & S, Vector const & V ) { if( Containment::isContainment(TestPointSphere(V,S)) ) return S; Vector normal = V - S.getCenter(); IGNORE_RETURN( normal.normalize() ); Vector pointS = S.getCenter() - normal * S.getRadius(); Vector center = Vector::midpoint(V,pointS); real radius = (V - pointS).magnitude() / 2.0f; return Sphere(center,radius); }
Sphere EncloseSphere ( Sphere const & A, Sphere const & B ) { if( Containment::isContainment(TestSphereSphere(A,B)) ) return B; if( Containment::isContainment(TestSphereSphere(B,A)) ) return A; // ---------- Vector normal = B.getCenter() - A.getCenter(); IGNORE_RETURN( normal.normalize() ); Vector pointA = A.getCenter() - normal * A.getRadius(); Vector pointB = B.getCenter() + normal * B.getRadius(); Vector center = Vector::midpoint(pointA,pointB); real radius = (pointB - pointA).magnitude() / 2.0f; return Sphere(center,radius); }
void TeleportFixupHandler::update(float time) { // Run through the list, trying to fix up any outstanding teleports and counting down the timers // When we try the teleport fixup, we force it if we've timed out, and we remove fixups from the // list when either the object cannot be found, is no longer authoritative, or succeeds at the // fixup (which it always will when forced). std::list<std::pair<Watcher<ServerObject>, float> >::iterator i = s_teleportFixups.begin(); while (i != s_teleportFixups.end()) { ServerObject *obj = (*i).first.getPointer(); (*i).second -= time; if (!obj || !obj->isAuthoritative() || obj->handleTeleportFixup((*i).second <= 0.0f)) { IGNORE_RETURN(s_teleportFixups.erase(i++)); if (obj) LOG("TeleportFixup", ("Removing %s from teleport fixup handler, was forced: %s\n", obj->getNetworkId().getValueString().c_str(), ((*i).second <= 0.0f) ? "true" : "false")); } else ++i; } }
ShipUpdateTransformMessage::ShipUpdateTransformMessage(uint16 shipId, Transform const &transform, Vector const &velocity, float yawRate, float pitchRate, float rollRate, uint32 syncStampLong) : GameNetworkMessage(s_shipUpdateTransformMessageName), m_shipId(shipId), m_transform(transform), m_velocity(velocity), m_yawRate(yawRate), m_pitchRate(pitchRate), m_rollRate(rollRate), m_syncStampLong(syncStampLong) { addVariable(m_shipId); addVariable(m_transform); addVariable(m_velocity); addVariable(m_yawRate); addVariable(m_pitchRate); addVariable(m_rollRate); addVariable(m_syncStampLong); #ifdef _DEBUG IGNORE_RETURN(transform.validate()); #endif }
static void safTerminate(SaInvocationT invocation, const SaNameT *compName) { if(gClMsgInit) { ClBoolT lockStatus = CL_TRUE; ClTimerTimeOutT timeout = { 0, 0}; clOsalMutexLock(&gClMsgFinalizeLock); while(gClMsgSvcRefCnt > 0) { clOsalCondWait(&gClMsgFinalizeCond, &gClMsgFinalizeLock, timeout); } safMsgFinalize(&lockStatus); if(lockStatus) { clOsalMutexUnlock(&gClMsgFinalizeLock); } } IGNORE_RETURN(saAmfComponentUnregister(amfHandle, compName, NULL)); clCpmClientFinalize(amfHandle); //clCpmResponse(cpmHandle, invocation, CL_OK); saAmfResponse(amfHandle, invocation, SA_AIS_OK); return; }