void Afterburner::_ShowCycle() { //m_Item->SetActive(true, 1253, m_Item->GetAttribute(AttrDuration).get_float(), true); double implantBonuses = 1.0; // TODO: gather and accumulate all implant bonuses for MWDs/Afterburners double accelerationControlSkillLevel = 0.0; // TODO: Figure out how to get access to skills list of character running this ship and get this value double boostSpeed = m_Ship->GetAttribute(AttrMaxVelocity).get_float() * (1.0 + (m_Item->GetAttribute(AttrSpeedFactor).get_float() / 100.0 * (1 + accelerationControlSkillLevel * 0.05) * (implantBonuses) * (m_Item->GetAttribute(AttrSpeedBoostFactor).get_float() / (m_Ship->GetAttribute(AttrMass).get_float())))); // Tell Destiny Manager about our new speed so it properly tracks ship movement: m_Ship->GetOperator()->GetDestiny()->SetMaxVelocity(boostSpeed); m_Ship->GetOperator()->GetDestiny()->SetSpeedFraction(1.0); DoDestiny_SetBallMass mass; mass.entityID = m_Ship->itemID(); mass.mass = m_Ship->GetAttribute(AttrMass).get_float(); DoDestiny_SetMaxSpeed speed; speed.entityID = m_Ship->itemID(); speed.speedValue = boostSpeed; std::vector<PyTuple *> updates; updates.push_back(mass.Encode()); updates.push_back(speed.Encode()); //m_Ship->GetOperator()->GetDestiny()->SendDestinyUpdate(updates, false); // Create Destiny Updates: Notify_OnGodmaShipEffect shipEff; shipEff.itemID = m_Item->itemID(); shipEff.effectID = 1254; // From EVEEffectID:: shipEff.when = Win32TimeNow(); shipEff.start = 1; shipEff.active = 1; PyList* env = new PyList; env->AddItem(new PyInt(shipEff.itemID)); env->AddItem(new PyInt(m_Ship->ownerID())); env->AddItem(new PyInt(m_Ship->itemID())); env->AddItem(new PyNone); env->AddItem(new PyNone); env->AddItem(new PyNone); env->AddItem(new PyInt(shipEff.effectID)); shipEff.environment = env; shipEff.startTime = shipEff.when; shipEff.duration = m_Item->GetAttribute(AttrDuration).get_float(); shipEff.repeat = new PyInt(1000); shipEff.randomSeed = new PyNone; shipEff.error = new PyNone; PyTuple* tmp = new PyTuple(3); //tmp->SetItem(1, dmgMsg.Encode()); tmp->SetItem(2, shipEff.Encode()); std::vector<PyTuple*> events; //events.push_back(dmgMsg.Encode()); events.push_back(shipEff.Encode()); //std::vector<PyTuple*> updates; //updates.push_back(dmgChange.Encode()); m_Ship->GetOperator()->GetDestiny()->SendDestinyUpdate(updates, events, false); // Create Special Effect: m_Ship->GetOperator()->GetDestiny()->SendSpecialEffect ( m_Ship, m_Item->itemID(), m_Item->typeID(), 0, 0, "effects.SpeedBoost", 0, 1, 1, m_Item->GetAttribute(AttrDuration).get_float(), 1000 ); }
PyRep *MarketDB::CreateContract( uint32 characterID, uint32 characterCorpID, uint32 type, uint32 avail, uint32 assigneeID, uint32 expiretime, uint32 duration, uint32 startStationID, uint32 endStationID, uint32 startSolarSystemID, uint32 endSolarSystemID, uint32 startRegionID, uint32 endRegionID, uint32 price, uint32 reward, uint32 collateral, std::string title, std::string description/*, std::vector<int32> itemsID, std::vector<int32> quantity, uint32 flag, std::vector<int32> requestItemID, std::vector<int32> requestItemQuantity*/, bool forCorp ) { DBerror err; DBQueryResult res; DBResultRow row; uint32 contractID = 0; uint64 timeNow = Win32TimeNow(); uint64 timeExpired = Win32TimeNow() + ((expiretime / 60) * Win32Time_Hour); uint8 numDays = ((expiretime / 60) * Win32Time_Hour) / Win32Time_Day ; if(endStationID == 0)endStationID = startStationID; if(!sDatabase.RunQuery(res, "SELECT solarSystemID, regionID" " FROM stastations" " WHERE stationID=%d", endStationID)) { codelog(MARKET__ERROR, "Error in query: %s", res.error.c_str() ); return NULL; } if( !res.GetRow(row) ) { codelog(MARKET__ERROR, "StationID %u not found", endStationID); return NULL; } endSolarSystemID = row.GetInt( 0 ); endRegionID = row.GetInt( 1 ); if(assigneeID == 0)assigneeID = characterID; if(!sDatabase.RunQueryLID(err, contractID, "INSERT INTO" " contract(" " contractID," " issuerID," " issuerCorpID," " type," " avail," " assigneeID," " expiretime," " duration," " startStationID," " endStationID," " startSolarSystemID," " endSolarSystemID," " startRegionID," " endRegionID," " price," " reward," " collateral," " title," " description," " forCorp," " status," " isAccepted," " acceptorID," " dateIssued," " dateExpired," " dateAccepted," " dateCompleted," " volume" // This should be the volume of all the items ")VALUES(" "NULL, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, '%s', '%s', %u, 0, false, NULL, " I64u ", " I64u ", NULL, " I64u ", 0)", characterID, characterCorpID, type, avail, assigneeID, expiretime, numDays, startStationID, endStationID, startSolarSystemID, endSolarSystemID, startRegionID, endRegionID, price, reward, collateral, "contract title", "contract description", forCorp, timeNow, timeExpired, timeExpired)) { codelog(MARKET__ERROR, "Error in query: %s", err.c_str() ); return NULL; } if(!forCorp) { if(!sDatabase.RunQuery(err, "UPDATE" " chrcontractinfo" " SET numOutStandingContractsNonCorp=numOutStandingContractsNonCorp+1," " numOutstandingContracts=numOutstandingContracts+1" " WHERE characterID=%d", characterID)) { codelog(MARKET__ERROR, "Error in query: %s", err.c_str() ); return NULL; } }else{ if(!sDatabase.RunQuery(err, "UPDATE" " chrcontractinfo" " SET numOutStandingContractsForCorp=numOutStandingContractsForCorp+1," " numOutstandingContracts=numOutstandingContracts+1" " WHERE characterID=%d", characterID)) { codelog(MARKET__ERROR, "Error in query: %s", err.c_str() ); return NULL; } } /*uint32 max = itemsID.capacity(); uint32 i = 0; for(i = 0; i <= max; i++) { if(!sDatabase.RunQuery(err, "INSERT INTO contracts_items(" " itemID," " contractID," " characterID," " quantity," " flag," " get" ") VALUES(" " %d, %d, %d, %d, 4, false)", itemsID.at(i), contractID, characterID, quantity.at(i) )) { codelog(MARKET__ERROR, "Error in query: %s", res.c_str() ); return NULL; } } max = requestItemID.capacity(); for(i = 0; i <= max; i++) { if(!sDatabase.RunQuery(err, "INSERT INTO contracts_items(" " itemID," " contractID," " characterID," " quantity," " flag," " get" ") VALUES(" " %d, %d, %d, %d, 4, true)", requestItemID.at(i), contractID, characterID, requestItemQuantity.at(i) )) { codelog(MARKET__ERROR, "Error in query: %s", res.c_str() ); return NULL; } }*/ return new PyInt( contractID ); }
int MailDB::SendMail(int sender, std::vector<int>& toCharacterIDs, int toListID, int toCorpOrAllianceID, std::string& title, std::string& body, int isReplyTo, int isForwardedFrom) { // build a string with ',' seperated char ids std::string toStr; for (size_t i = 0; i < toCharacterIDs.size(); i++) { toStr += itoa(toCharacterIDs[i]); // only add ',' when this isn't the last ID if (i != (toCharacterIDs.size() - 1)) toStr += ","; } // sanitize these ids if (toListID == -1) toListID = 0; if (toCorpOrAllianceID == -1) toCorpOrAllianceID = 0; // compress the body Buffer bodyCompressed; Buffer bodyInput(body.begin(), body.end()); DeflateData(bodyInput, bodyCompressed); // ugh - buffer doesn't give us the actual buffer.. what the? std::string bodyCompressedStr(bodyCompressed.begin<char>(), bodyCompressed.end<char>()); // escape it to not break the query with special characters std::string bodyEscaped; sDatabase.DoEscapeString(bodyEscaped, bodyCompressedStr); // default label is 1 = Inbox const int defaultLabel = 1; DBerror err; uint32 messageID; bool status = sDatabase.RunQueryLID(err, messageID, "INSERT INTO mailMessage (senderID, toCharacterIDs, toListID, toCorpOrAllianceID, title, body, sentDate, statusMask, labelMask, unread) " " VALUES (%u, '%s', %d, %d, '%s', '%s', " PRIu64 ", 0, %u, 1)", sender, toStr.c_str(), toListID, toCorpOrAllianceID, title.c_str(), bodyEscaped.c_str(), Win32TimeNow(), defaultLabel); if (!status) return 0; return messageID; }
PyResult BookmarkService::Handle_BookmarkLocation(PyCallArgs &call) { std::string label; std::string note; std::string memo; uint32 bookmarkID = 0; uint32 ownerID = call.client->GetCharacterID(); uint32 itemID = 0; uint32 typeID = 0; uint32 flag = 0; uint64 created = 0; uint32 locationID = 0; GPoint point; //////////////////////////////////////// // Verify expected packet structure: // // call.tuple // | // |--> [0] PyInt: itemID for bookmark location (itemID from entity table, stargateID from mapjumps table, etc) // |--> [1] PyWString: label for the bookmark // \--> [2] PyWString: text for the "note" field in the bookmark (NOTE: this type will be PyString when it equals "") //////////////////////////////////////// if ( (call.tuple->size() < 3) ) { sLog.Error( "BookmarkService::Handle_BookmarkLocation()", "%s: call.tuple is of size %u, expected 3.", call.client->GetName(), call.tuple->size() ); return NULL; } if ( !(call.tuple->IsTuple()) ) { sLog.Error( "BookmarkService::Handle_BookmarkLocation()", "%s: call.tuple is of the wrong type: '%s'. Expected PyTuple type.", call.client->GetName(), call.tuple->TypeString() ); return NULL; } if ( !(call.tuple->GetItem(0)->IsInt()) ) { sLog.Error( "BookmarkService::Handle_BookmarkLocation()", "%s: call.tuple->GetItem(0) is of the wrong type: '%s'. Expected PyInt type.", call.client->GetName(), call.tuple->GetItem(0)->TypeString() ); return NULL; } else itemID = call.tuple->GetItem( 0 )->AsInt()->value(); if ( call.tuple->GetItem( 1 )->IsString() ) label = call.tuple->GetItem( 1 )->AsString()->content(); else if ( call.tuple->GetItem( 1 )->IsWString() ) label = call.tuple->GetItem( 1 )->AsWString()->content(); else { sLog.Error( "BookmarkService::Handle_BookmarkLocation()", "%s: call.tuple->GetItem(1) is of the wrong type: '%s'. Expected PyString or PyWString type.", call.client->GetName(), call.tuple->GetItem(2)->TypeString() ); return NULL; } if ( call.tuple->GetItem( 2 )->IsString() ) note = call.tuple->GetItem( 2 )->AsString()->content(); else if ( call.tuple->GetItem( 2 )->IsWString() ) note = call.tuple->GetItem( 2 )->AsWString()->content(); else { sLog.Error( "BookmarkService::Handle_BookmarkLocation()", "%s: call.tuple->GetItem(2) is of the wrong type: '%s'. Expected PyString or PyWString type.", call.client->GetName(), call.tuple->GetItem(3)->TypeString() ); return NULL; } // Get typeID for this itemID: typeID = m_db.FindBookmarkTypeID(itemID); // Get x,y,z location in space of the character: point = call.client->GetPosition(); // Get locationID for this character: locationID = call.client->GetLocationID(); //////////////////////////////////////// // Save bookmark info to database: //////////////////////////////////////// flag = 0; // Don't know what to do with this value created = Win32TimeNow(); memo = label + note; m_db.SaveNewBookmarkToDatabase ( bookmarkID, call.client->GetCharacterID(), itemID, typeID, flag, memo, created, point.x, point.y, point.z, locationID ); //////////////////////////////////////// // Build return packet: // // (bookmarkID, itemID, typeID, x, y, z, locationID,) //////////////////////////////////////// PyTuple* res = NULL; PyTuple* tuple0 = new PyTuple( 7 ); tuple0->items[ 0 ] = new PyInt( bookmarkID ); // Bookmark ID from Database 'bookmarks' table tuple0->items[ 1 ] = new PyNone(); // in some cases, this is the itemID tuple0->items[ 2 ] = new PyInt( typeID ); // typeID from invTypes tuple0->items[ 3 ] = new PyInt( (uint32)(point.x) ); // X coordinate tuple0->items[ 4 ] = new PyInt( (uint32)(point.y) ); // Y coordinate tuple0->items[ 5 ] = new PyInt( (uint32)(point.z) ); // Z coordinate tuple0->items[ 6 ] = new PyInt( locationID ); // systemID res = tuple0; return res; }
void Character::UpdateSkillQueue() { Client *c = m_factory.entity_list.FindCharacter( itemID() ); SkillRef currentTraining = GetSkillInTraining(); if( currentTraining ) { if( m_skillQueue.empty() || currentTraining->typeID() != m_skillQueue.front().typeID ) { // either queue is empty or skill with different typeID is in training ... // stop training: _log( ITEM__ERROR, "%s (%u): Stopping training of skill %s (%u).", itemName().c_str(), itemID(), currentTraining->itemName().c_str(), currentTraining->itemID() ); uint64 timeEndTrain = currentTraining->expiryTime(); if(timeEndTrain != 0) { double nextLevelSP = currentTraining->GetSPForLevel( currentTraining->skillLevel() + 1 ); double SPPerMinute = GetSPPerMin( currentTraining ); double minRemaining = (double)(timeEndTrain - Win32TimeNow()) / (double)Win32Time_Minute; currentTraining->Set_skillPoints( nextLevelSP - (minRemaining * SPPerMinute) ); } currentTraining->Clear_expiryTime(); currentTraining->MoveInto( *this, flagSkill, true ); if( c != NULL ) { OnSkillTrainingStopped osst; osst.itemID = currentTraining->itemID(); osst.endOfTraining = 0; PyTuple* tmp = osst.Encode(); c->QueueDestinyEvent( &tmp ); PySafeDecRef( tmp ); c->UpdateSkillTraining(); } // nothing currently in training currentTraining = SkillRef(); } } uint64 nextStartTime = Win32TimeNow(); while( !m_skillQueue.empty() ) { if( !currentTraining ) { // something should be trained, get desired skill uint32 skillTypeID = m_skillQueue.front().typeID; currentTraining = GetSkill( skillTypeID ); if( !currentTraining ) { _log( ITEM__ERROR, "%s (%u): Skill %u to train was not found.", itemName().c_str(), itemID(), skillTypeID ); break; } _log( ITEM__TRACE, "%s (%u): Starting training of skill %s (%u).", m_itemName.c_str(), m_itemID, currentTraining->itemName().c_str(), currentTraining->itemID() ); double SPPerMinute = GetSPPerMin( currentTraining ); double SPToNextLevel = currentTraining->GetSPForLevel( currentTraining->skillLevel() + 1 ) - currentTraining->skillPoints(); uint64 timeTraining = nextStartTime + Win32Time_Minute * SPToNextLevel / SPPerMinute; currentTraining->MoveInto( *this, flagSkillInTraining ); currentTraining->Set_expiryTime( timeTraining ); if( c != NULL ) { OnSkillStartTraining osst; osst.itemID = currentTraining->itemID(); osst.endOfTraining = timeTraining; PyTuple* tmp = osst.Encode(); c->QueueDestinyEvent( &tmp ); PySafeDecRef( tmp ); c->UpdateSkillTraining(); } } if( currentTraining->expiryTime() <= Win32TimeNow() ) { // training has been finished: _log( ITEM__ERROR, "%s (%u): Finishing training of skill %s (%u).", itemName().c_str(), itemID(), currentTraining->itemName().c_str(), currentTraining->itemID() ); currentTraining->Set_skillLevel( currentTraining->skillLevel() + 1 ); currentTraining->Set_skillPoints( currentTraining->GetSPForLevel( currentTraining->skillLevel() ) ); nextStartTime = currentTraining->expiryTime(); currentTraining->Clear_expiryTime(); currentTraining->MoveInto( *this, flagSkill, true ); if( c != NULL ) { OnSkillTrained ost; ost.itemID = currentTraining->itemID(); PyTuple* tmp = ost.Encode(); c->QueueDestinyEvent( &tmp ); PySafeDecRef( tmp ); c->UpdateSkillTraining(); } // erase first element in skill queue m_skillQueue.erase( m_skillQueue.begin() ); // nothing currently in training currentTraining = SkillRef(); } // else the skill is in training ... else break; } SaveSkillQueue(); }
PyRep* CharacterDB::DeleteCharacter(uint32 accountID, uint32 charID) { DBerror error; uint32 affectedRows; sDatabase.RunQuery(error, affectedRows, "DELETE FROM character_ WHERE deletePrepareDateTime > 0 AND deletePrepareDateTime <= " I64u " AND accountID = %u AND characterID = %u", Win32TimeNow(), accountID, charID); if (affectedRows == 1) { // valid request; this means we may use charID safely here sDatabase.RunQuery(error, "DELETE FROM entity WHERE ownerID = %u", charID); // indicates 'no error' to the client return NULL; } else return new PyString("Invalid delete request"); }