secondlife
Member
- Joined
- Aug 1, 2009
- Messages
- 298
- Reaction score
- 23
Hi guys!
Can someone who has a advanced knowledge try to help me in this?
First of all, im using OTHire: TwistedScorpio/OTHire (https://github.com/TwistedScorpio/OTHire/blob/master/source/ioplayer.cpp)
As follows, this function IOPlayer::getPlayerUnjustKillCount is in ioplayer.cpp file. My question is: would it be possible to create a function that would update (refresh/reload) this function "getPlayerUnjustKillCount"? Because it is always necessary restart the server for the frags to be updated (clear).
In ioplayer.cpp:
Many thanks!!!
Can someone who has a advanced knowledge try to help me in this?
First of all, im using OTHire: TwistedScorpio/OTHire (https://github.com/TwistedScorpio/OTHire/blob/master/source/ioplayer.cpp)
As follows, this function IOPlayer::getPlayerUnjustKillCount is in ioplayer.cpp file. My question is: would it be possible to create a function that would update (refresh/reload) this function "getPlayerUnjustKillCount"? Because it is always necessary restart the server for the frags to be updated (clear).
In ioplayer.cpp:
Code:
int32_t IOPlayer::getPlayerUnjustKillCount(const Player* player, UnjustKillPeriod_t period)
{
time_t currentTime = std::time(NULL);
int64_t date = 0;
switch(period){
case UNJUST_KILL_PERIOD_DAY:
date = currentTime - 24 * 60 * 60;
break;
case UNJUST_KILL_PERIOD_WEEK:
date = currentTime - 7 * 24 * 60 * 60;
break;
case UNJUST_KILL_PERIOD_MONTH:
date = currentTime - 30 * 24 * 60 * 60;
break;
default:
return 0;
break;
}
UnjustKillBlock uk;
UnjustCacheMap::iterator it = unjustKillCacheMap.find(player->getGUID());
if(it != unjustKillCacheMap.end()){
uk = it->second;
switch(period){
case UNJUST_KILL_PERIOD_DAY:
if(it->second.dayExpireTime < currentTime && it->second.dayQueryTime > 0 && date >= it->second.dayQueryTime){
return it->second.dayUnjustCount;
}
break;
case UNJUST_KILL_PERIOD_WEEK:
if(it->second.weekExpireTime < currentTime && it->second.weekQueryTime > 0 && date >= it->second.weekQueryTime){
return it->second.weekUnjustCount;
}
break;
case UNJUST_KILL_PERIOD_MONTH:
if(it->second.monthExpireTime < currentTime && it->second.monthQueryTime > 0 && date >= it->second.monthQueryTime){
return it->second.monthUnjustCount;
}
break;
}
}
Database* db = Database::instance();
DBQuery query;
DBResult* result;
query << "SELECT `date` ";
query << "FROM ";
query << "`player_killers` ";
query << "LEFT JOIN ";
query << "`killers` ON `killers`.`id` = `player_killers`.`kill_id` ";
query << "LEFT JOIN ";
query << "`player_deaths` on `player_deaths`.`id` = `killers`.`death_id` ";
query << "LEFT JOIN ";
query << "`players` on `players`.`id` = `player_deaths`.`player_id` ";
query << "WHERE ";
query << "`player_killers`.`player_id` = " << player->getGUID() << " "
<< "AND " << "`player_killers`.`unjustified` = " << " 1 "
<< "AND " << date << " < `player_deaths`.`date` "
<< "ORDER BY `player_deaths`.`date` ASC";
if(!(result = db->storeQuery(query.str())))
return 0;
int64_t expireTime = 0;
uint32_t count = 0;
do{
if(count == 0){
expireTime = result->getDataLong("date");
}
++count;
}while(result->next());
switch(period){
case UNJUST_KILL_PERIOD_DAY:
uk.dayQueryTime = date;
uk.dayExpireTime = expireTime;
uk.dayUnjustCount = count;
break;
case UNJUST_KILL_PERIOD_WEEK:
uk.weekQueryTime = date;
uk.weekExpireTime = expireTime;
uk.weekUnjustCount = count;
break;
case UNJUST_KILL_PERIOD_MONTH:
uk.monthQueryTime = date;
uk.monthExpireTime = expireTime;
uk.monthUnjustCount = count;
break;
default:
return 0;
break;
}
unjustKillCacheMap[player->getGUID()] = uk;
db->freeResult(result);
return count;
}
Many thanks!!!