bool psEntity::CanPlay(int time, float range) const { EntityState* entityState; // checking if it is in the undefined state entityState = states.Get(state, 0); if(entityState == 0) { Debug3(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u undefined state.", entityName.GetData(), GetMeshID()); return false; } // checking time, range and delay if(range < minRange || range > maxRange) { Debug6(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u range %f %f %f", entityName.GetData(),GetMeshID(), minRange, range, maxRange); return false; } else if(time < entityState->timeOfDayStart || entityState->timeOfDayEnd < time) { Debug6(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u time of day %d %d %d", entityName.GetData(),GetMeshID(), entityState->timeOfDayStart,time,entityState->timeOfDayEnd); return false; } else if(when <= 0) { Debug4(LOG_SOUND, 0, "psEntity::CanPlay TRUE %s meshid: %u when <0 : %d", entityName.GetData(),GetMeshID(), when); return true; } Debug4(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u when : %d", entityName.GetData(),GetMeshID(), when); return false; }
int Execvp(const char *file, char *const argv[]) { int result, _errno; if (argv[1] == NULL) Debug2("execvp(\"%s\", \"%s\")", file, argv[0]); else if (argv[2] == NULL) Debug3("execvp(\"%s\", \"%s\" \"%s\")", file, argv[0], argv[1]); else if (argv[3] == NULL) Debug4("execvp(\"%s\", \"%s\" \"%s\" \"%s\")", file, argv[0], argv[1], argv[2]); else if (argv[4] == NULL) Debug5("execvp(\"%s\", \"%s\" \"%s\" \"%s\" \"%s\")", file, argv[0], argv[1], argv[2], argv[3]); else if (argv[5] == NULL) Debug6("execvp(\"%s\", \"%s\" \"%s\" \"%s\" \"%s\" \"%s\")", file, argv[0], argv[1], argv[2], argv[3], argv[4]); else Debug6("execvp(\"%s\", \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" ...)", file, argv[0], argv[1], argv[2], argv[3], argv[4]); result = execvp(file, argv); _errno = errno; Debug1("execvp() -> %d", result); errno = _errno; return result; }
int Uname(struct utsname *buf) { int result, _errno; Debug1("uname(%p)", buf); result = uname(buf); _errno = errno; #if UNAME_DOMAINNAME Debug6("uname({%s, %s, %s, %s, %s, %s})", buf->sysname, buf->nodename, buf->release, buf->version, buf->machine, buf->domainname); #else Debug5("uname({%s, %s, %s, %s, %s})", buf->sysname, buf->nodename, buf->release, buf->version, buf->machine); #endif errno = _errno; return result; }
int Setsockopt(int s, int level, int optname, const void *optval, int optlen) { int result, _errno; if (optlen <= sizeof(int)) { Debug5("setsockopt(%d, %d, %d, {0x%x}, %d)", s, level, optname, *(unsigned int *)optval, optlen); } else { Debug6("setsockopt(%d, %d, %d, {0x%08x,%08x}, %d)", s, level, optname, ((unsigned int *)optval)[0], ((unsigned int *)optval)[1], optlen); } result = setsockopt(s, level, optname, optval, optlen); _errno = errno; Debug1("setsockopt() -> %d", result); errno = _errno; return result; }
int Tcgetattr(int fd, struct termios *termios_p) { int i, result, _errno; char chars[5*NCCS], *cp = chars; Debug2("tcgetattr(%d, %p)", fd, termios_p); result = tcgetattr(fd, termios_p); _errno = errno; for (i = 0; i < NCCS-1; ++i) { cp += sprintf(cp, "%02x,", termios_p->c_cc[i]); } sprintf(cp, "%02x", termios_p->c_cc[i]); Debug6("tcgetattr(, {%08x,%08x,%08x,%08x,%s}) -> %d", termios_p->c_iflag, termios_p->c_oflag, termios_p->c_cflag, termios_p->c_lflag, chars, result); errno = _errno; return result; }
int Recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) { int retval, _errno; char infobuff[256]; Debug6("recvfrom(%d, %p, "F_Zu", %d, %p, "F_Zu")", s, buf, len, flags, from, *fromlen); retval = recvfrom(s, buf, len, flags, from, fromlen); _errno = errno; if (from) { Debug4("recvfrom(,,,, {%d,%s}, "F_Zd") -> %d", from->sa_family, sockaddr_info(from, *fromlen, infobuff, sizeof(infobuff)), *fromlen, retval); } else { Debug1("recvfrom(,,,, NULL, NULL) -> %d", retval); } errno = _errno; return retval; }
bool PaladinJr::SpeedCheck(Client* client, gemActor* actor, psDRMessage& currUpdate) { csVector3 oldpos; // Dummy variables float yrot; iSector* sector; psWorld * world = entitymanager->GetWorld(); int violation = NOVIOLATION; actor->pcmove->GetLastClientPosition (oldpos, yrot, sector); // If no previous observations then we have nothing to check against. if (!sector) return true; // define cheating variables float dist; float reported_distance; float max_noncheat_distance; float lag_distance; csTicks timedelta; csVector3 vel; // check for warpviolation if (sector != currUpdate.sector && !world->WarpSpace(sector, currUpdate.sector, oldpos)) { if (checks & WARPVIOLATION) { violation = WARPVIOLATION; } else { // we don't do warp checking and crossed a sector // skip this round return true; } } if (checks & SPEEDVIOLATION) { // we don't use the absolute value of the vertical // speed in order to let falls go through if (fabs(currUpdate.vel.x) <= maxVelocity.x && currUpdate.vel.y <= maxVelocity.y && fabs(currUpdate.vel.z) <= maxVelocity.z) { violation |= SPEEDVIOLATION; } } // distance check is skipped on warp violation as it would be wrong if (checks & DISTVIOLATION && !(violation & WARPVIOLATION)) { dist = (currUpdate.pos-oldpos).Norm(); timedelta = actor->pcmove->ClientTimeDiff(); // We use the last reported vel, not the new vel, to calculate how far he should have gone since the last DR update vel = actor->pcmove->GetVelocity(); vel.y = 0; // ignore vertical velocity reported_distance = vel.Norm()*timedelta/1000; Debug4(LOG_CHEAT, client->GetClientNum(),"Player went %1.3fm in %u ticks when %1.3fm was allowed.\n",dist, timedelta, reported_distance); max_noncheat_distance = maxSpeed*timedelta/1000; lag_distance = maxSpeed*client->accumulatedLag/1000; if (dist < max_noncheat_distance + lag_distance) { if(dist == 0) { // player is stationary - reset accumulated lag NetBase::Connection * connection = client->GetConnection(); client->accumulatedLag = connection->estRTT + connection->devRTT; } else if(fabs(dist-reported_distance) < dist/20) { // ignore jitter caused differences Debug1(LOG_CHEAT, client->GetClientNum(),"Ignoring lag jitter."); } else { // adjust accumulated lag float lag = (reported_distance - dist) * 1000.f/maxSpeed + client->accumulatedLag; // cap to meaningful values lag = lag < 0 ? 0 : lag > MAX_ACCUMULATED_LAG ? MAX_ACCUMULATED_LAG : lag; client->accumulatedLag = (csTicks)lag; Debug2(LOG_CHEAT, client->GetClientNum(),"Accumulated lag: %u\n",client->accumulatedLag); } } else { violation |= DISTVIOLATION; } } if (violation != NOVIOLATION) { if (client->GetCheatMask(MOVE_CHEAT)) { //printf("Server has pre-authorized this apparent speed violation.\n"); client->SetCheatMask(MOVE_CHEAT, false); // now clear the Get Out of Jail Free card return true; // not cheating } Debug6(LOG_CHEAT, client->GetClientNum(),"Went %1.2f in %u ticks when %1.2f was expected plus %1.2f allowed lag distance (%1.2f)\n", dist, timedelta, max_noncheat_distance, lag_distance, max_noncheat_distance+lag_distance); //printf("Z Vel is %1.2f\n", currUpdate.vel.z); //printf("MaxSpeed is %1.2f\n", maxSpeed); // Report cheater csVector3 angVel; csString buf; csString type; csString sectorName(sector->QueryObject()->GetName()); // Player has probably been warped if (violation & WARPVIOLATION) { sectorName.Append(" to "); sectorName.Append(currUpdate.sectorName); type = "Warp Violation"; } if (violation & SPEEDVIOLATION) { if(!type.IsEmpty()) type += "|"; type += "Speed Violation (Hack confirmed)"; } if (violation & DISTVIOLATION) { if(!type.IsEmpty()) type += "|"; type += "Distance Violation"; } if (enforcing) { actor->ForcePositionUpdate(); } actor->pcmove->GetAngularVelocity(angVel); buf.Format("%s, %s, %s, %.3f %.3f %.3f, %.3f 0 %.3f, %.3f %.3f %.3f, %.3f %.3f %.3f, %.3f %.3f %.3f, %s\n", client->GetName(), type.GetData(), sectorName.GetData(),oldpos.x, oldpos.y, oldpos.z, max_noncheat_distance, max_noncheat_distance, currUpdate.pos.x - oldpos.x, currUpdate.pos.y - oldpos.y, currUpdate.pos.z - oldpos.z, vel.x, vel.y, vel.z, angVel.x, angVel.y, angVel.z, PALADIN_VERSION); psserver->GetLogCSV()->Write(CSV_PALADIN, buf); Debug5(LOG_CHEAT, client->GetClientNum(),"Player %s traversed %1.2fm in %u msec with an accumulated lag allowance of %u ms. Cheat detected!\n", client->GetName (),dist,timedelta,client->accumulatedLag); client->CountDetectedCheat(); //printf("Client has %d detected cheats now.\n", client->GetDetectedCheatCount()); if (client->GetDetectedCheatCount() % warnCount == 0) { psserver->SendSystemError(client->GetClientNum(),"You have been flagged as using speed hacks. You will be disconnected if you continue."); } if (client->GetDetectedCheatCount() >= maxCount) { //printf("Disconnecting a cheating client.\n"); psserver->RemovePlayer(client->GetClientNum(),"Paladin has kicked you from the server for cheating."); return false; } return !enforcing; } else { return true; } }