okay, finally!!! the leader now can force another users char to participate in the clanfight, even if they have the "Kampf" or "Schatzsuche Status" depending if they can be fetched ("abgeholen")

main
hecht 13 years ago
parent cf1ccd8d6c
commit 04cac8c623

@ -263,7 +263,7 @@ function cancelChallengeRequest($challenged_clan, array $user) {
} }
$sql = 'SELECT * FROM clan_challenge_requests WHERE clan_challenged = ' .$challenged_clan . ' AND clan_requester = ' .$user['clan'] . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())'; $sql = 'SELECT * FROM clan_challenge_requests WHERE clan_challenged = ' .$challenged_clan . ' AND clan_requester = ' .$user['clan'] . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())';
// echo $sql .'<br>'; // echo $sql .'<br>';
$clan_challenge = mysql_fetch_assoc(mysql_query($sql)); $clan_challenge = mysql_fetch_assoc(mysql_query($sql));
if(!$clan_challenge) { if(!$clan_challenge) {
@ -308,7 +308,7 @@ function denyChallengeRequest($challenge_requester, array $user) {
} }
$sql = 'SELECT * FROM clan_challenge_requests WHERE clan_challenged = ' .$user['clan'] . ' AND clan_requester = ' .$challenge_requester . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())'; $sql = 'SELECT * FROM clan_challenge_requests WHERE clan_challenged = ' .$user['clan'] . ' AND clan_requester = ' .$challenge_requester . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())';
// echo $sql . '<br>'; // echo $sql . '<br>';
$clan_challenge = mysql_fetch_assoc(mysql_query($sql)); $clan_challenge = mysql_fetch_assoc(mysql_query($sql));
if(!$clan_challenge) { if(!$clan_challenge) {
@ -428,7 +428,7 @@ function getAwatingChallengeIDs() {
// before doing anything check if we are locked // before doing anything check if we are locked
$array = array(); $array = array();
$sql = 'SELECT distinct(cc.clan_challenge_id) FROM clan_challenges AS cc inner join clan_challenge_clans AS ccp ON cc.clan_challenge_id = ccp.clan_challenge_id WHERE elo_change is null AND calculated = TRUE AND enddate < now()'; $sql = 'SELECT distinct(cc.clan_challenge_id) FROM clan_challenges AS cc inner join clan_challenge_clans AS ccp ON cc.clan_challenge_id = ccp.clan_challenge_id WHERE elo_change is null AND calculated = TRUE AND enddate < now()';
// echo $sql . '<br>'; // echo $sql . '<br>';
$qry = mysql_query($sql); $qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) { while($row = mysql_fetch_row($qry)) {
$array[] = $row[0]; $array[] = $row[0];
@ -504,7 +504,7 @@ function getClanLockedTime($clan_id) {
$sql = 'SELECT TIMESTAMPDIFF(SECOND, NOW(), locked_until) FROM clan_locked WHERE clanid = ' . $clan_id; $sql = 'SELECT TIMESTAMPDIFF(SECOND, NOW(), locked_until) FROM clan_locked WHERE clanid = ' . $clan_id;
$row = mysql_fetch_row(mysql_query($sql)); $row = mysql_fetch_row(mysql_query($sql));
if($row) if($row)
return $row[0]; return $row[0];
return 0; return 0;
} }
@ -538,7 +538,7 @@ function isClanLocked($clanid) {
// echo $sql.'<br>'; // echo $sql.'<br>';
$res = mysql_query($sql); $res = mysql_query($sql);
if(!$res) if(!$res)
echo $sql . '<br>'; echo $sql . '<br>';
mysql_query('UPDATE clan_challenge_requests SET active = FALSE WHERE (clan_challenged = '.$clanid.' OR clan_requester = '.$clanid); mysql_query('UPDATE clan_challenge_requests SET active = FALSE WHERE (clan_challenged = '.$clanid.' OR clan_requester = '.$clanid);
mysql_query('DELETE FROM clan_challenges WHERE calculated = FALSE AND clan_challenge_id IN (SELECT clan_challenge_id from clan_challenge_clans WHERE clan_id = '.$clanid.')'); mysql_query('DELETE FROM clan_challenges WHERE calculated = FALSE AND clan_challenge_id IN (SELECT clan_challenge_id from clan_challenge_clans WHERE clan_id = '.$clanid.')');
} else if($lock['members'] < MIN_MEMBERS){ // we have to update the actual row } else if($lock['members'] < MIN_MEMBERS){ // we have to update the actual row
@ -546,15 +546,15 @@ function isClanLocked($clanid) {
$sql = 'UPDATE clan_locked set locked_until = TIMESTAMPADD(HOUR, 24, CURRENT_TIMESTAMP) WHERE clanid = ' .$clanid; $sql = 'UPDATE clan_locked set locked_until = TIMESTAMPADD(HOUR, 24, CURRENT_TIMESTAMP) WHERE clanid = ' .$clanid;
// echo $sql.'<br>'; // echo $sql.'<br>';
$res = mysql_query($sql); $res = mysql_query($sql);
if(!$res) if(!$res)
echo $sql . '<br>'; echo $sql . '<br>';
} }
} else if($lock['members'] < MIN_MEMBERS) { } else if($lock['members'] < MIN_MEMBERS) {
$sql = 'UPDATE clan_locked set locked_until = TIMESTAMPADD(HOUR, 24, CURRENT_TIMESTAMP) WHERE clanid = ' .$clanid; $sql = 'UPDATE clan_locked set locked_until = TIMESTAMPADD(HOUR, 24, CURRENT_TIMESTAMP) WHERE clanid = ' .$clanid;
// echo $sql.'<br>'; // echo $sql.'<br>';
$res = mysql_query($sql); $res = mysql_query($sql);
if(!$res) if(!$res)
echo $sql . '<br>'; echo $sql . '<br>';
} }
return true; return true;
} }
@ -593,13 +593,25 @@ function joinChallenge($clan_challenge_id, array $user, $charid, $slot ) {
} }
if($char['status'] != 'Frei') { if($char['status'] != 'Frei') {
// char is not free but is he already participating? if($forced && ($char['status'] == 'Kampf' || $char['status'] == 'Schatz Suche')) { // foreign assignment may also possible if the status is in "fetching" state
$participant = getParticipatingChar($clan_challenge_id, $clan['id'], $charid); // okay now check if the fetch-time is reached!!
if(!$participant || !$participant['forced']) { if($char['status'] == 'Schatz Suche') {
return 'Du kannst den Char nicht an dem Kampf teilnehmen lassen, da er nicht frei ist!'; $row = mysql_fetch_row(db_query('SELECT Timestampdiff(Second,now(),dauer) as dauer from quests where charid = '.$charid));
} else {
$row = mysql_fetch_row(db_query('SELECT dauer - ' . time() . ' FROM kampf WHERE db_satz='.$charid ));
}
if($row[0] > 0) {
return 'Du kannst den Char \''.$char['name'].'\' nicht an dem Kampf teilnehmen lassen, da er im Moment noch f&uuml;r ' . $row[0] . ' Sekunden mit ' . $char['status']. ' besch&auml;ftigt ist!';
}
} else {
// char is not free but is he already participating?
$participant = getParticipatingChar($clan_challenge_id, $clan['id'], $charid);
if(!$participant || !$participant['forced']) {
return 'Du kannst den Char nicht an dem Kampf teilnehmen lassen, da er nicht frei ist!';
}
db_query('UPDATE clan_challenge_participants SET forced = FALSE WHERE clan_challenge_id = ' . $clan_challenge_id . ' AND clan_id = '.$clan['id'].' AND char_id = ' . $charid);
return NULL;
} }
db_query('UPDATE clan_challenge_participants SET forced = FALSE WHERE clan_challenge_id = ' . $clan_challenge_id . ' AND clan_id = '.$clan['id'].' AND char_id = ' . $charid);
return NULL;
} }
$clan_challenge = getChallenge($clan_challenge_id); $clan_challenge = getChallenge($clan_challenge_id);
@ -780,10 +792,10 @@ function cancelChallenge($clan_challenge_id, array $user) {
// kay, finish him !!! // kay, finish him !!!
$sql = 'DELETE FROM clan_challenges WHERE clan_challenge_id = ' .$clan_challenge_id . ' AND calculated = FALSE'; $sql = 'DELETE FROM clan_challenges WHERE clan_challenge_id = ' .$clan_challenge_id . ' AND calculated = FALSE';
// echo $sql . '<br>'; // echo $sql . '<br>';
$res = mysql_query($sql); $res = mysql_query($sql);
if(!$res) if(!$res)
return 'Beim zur&uuml;ckziehen des Clan-Fights ist ein technischer Fehler aufgetreten!'; return 'Beim zur&uuml;ckziehen des Clan-Fights ist ein technischer Fehler aufgetreten!';
foreach ($user_to_notify as $userid) { foreach ($user_to_notify as $userid) {
sendMessage($user['nickname'], $userid, 'Clan-Fight', 'Der Clan '.$clan['clanname'].' hat den Clan-Fight zurückgezogen!'); sendMessage($user['nickname'], $userid, 'Clan-Fight', 'Der Clan '.$clan['clanname'].' hat den Clan-Fight zurückgezogen!');
@ -829,12 +841,12 @@ function calculateChallenge($clan_challenge_id) {
case DAVY_BACK_FIGHT: case DAVY_BACK_FIGHT:
$result = calculateDavyBackClanFight($clan_challenge_id, $event_id, $clan_ids, $clan_chars, $start_time); $result = calculateDavyBackClanFight($clan_challenge_id, $event_id, $clan_ids, $clan_chars, $start_time);
if(!is_numeric($result)) if(!is_numeric($result))
return $result; return $result;
break; break;
case SURVIVAL: case SURVIVAL:
$result = calculateSurvivalClanFight($clan_challenge_id, $event_id, $clan_ids, $clan_chars, $start_time); $result = calculateSurvivalClanFight($clan_challenge_id, $event_id, $clan_ids, $clan_chars, $start_time);
if(!is_numeric($result)) if(!is_numeric($result))
return $result; return $result;
break; break;
default: default:
// cannot create anything -.- // cannot create anything -.-
@ -992,12 +1004,12 @@ function updateAuthorizedClanfightCoordinators($clan_id, array $user_ids) {
$remove = array_diff($ids, $user_ids); $remove = array_diff($ids, $user_ids);
$sql = 'DELETE FROM `clan_challenge_whitelist` WHERE `user_id` IN (' . implode(',', $remove) .') AND `clan_id` = ' . $clan_id; $sql = 'DELETE FROM `clan_challenge_whitelist` WHERE `user_id` IN (' . implode(',', $remove) .') AND `clan_id` = ' . $clan_id;
// echo $sql . '<br>'; // echo $sql . '<br>';
mysql_query($sql); mysql_query($sql);
foreach($add as $user_id) { foreach($add as $user_id) {
$sql = 'INSERT INTO `clan_challenge_whitelist`(`user_id`, `clan_id`) values('.$user_id.', '.$clan_id.')'; $sql = 'INSERT INTO `clan_challenge_whitelist`(`user_id`, `clan_id`) values('.$user_id.', '.$clan_id.')';
// echo $sql . '<br>'; // echo $sql . '<br>';
mysql_query($sql); mysql_query($sql);
} }
} }
@ -1023,7 +1035,7 @@ function isAuthorizedClanfightCoordinator($clan_id, $user_id, $clan_fight_id = N
// do we require this information for a specific clan_fight??? // do we require this information for a specific clan_fight???
if($clan_fight_id !== NULL) { if($clan_fight_id !== NULL) {
$sql = 'SELECT COUNT(*) FROM `clan_challenge_clans` WHERE `clan_coordinator` = ' .$user_id. ' AND `clan_id` = '.$clan_id . ' AND `clan_challenge_id` = ' .$clan_fight_id; $sql = 'SELECT COUNT(*) FROM `clan_challenge_clans` WHERE `clan_coordinator` = ' .$user_id. ' AND `clan_id` = '.$clan_id . ' AND `clan_challenge_id` = ' .$clan_fight_id;
// echo $sql . '<br>'; // echo $sql . '<br>';
$row = mysql_fetch_row(mysql_query($sql)); $row = mysql_fetch_row(mysql_query($sql));
if($row[0] <= 0) { if($row[0] <= 0) {
// okay, maybe its a leader ;) // okay, maybe its a leader ;)

@ -35,15 +35,15 @@ $GLOBALS['semaphorecount'] = 0;
* @param string $resource the name of the resource * @param string $resource the name of the resource
*/ */
function semaphoreUP($resource){ function semaphoreUP($resource){
// echo 'semaphoreUp('.$ressource.')<br>' . PHP_EOL ; // echo 'semaphoreUp('.$resource.')<br>' . PHP_EOL ;
if($GLOBALS['semaphorecount'] == 0){ if($GLOBALS['semaphorecount'] == 0){
ignore_user_abort(true); // Verarbeitung darf NICHT abgebrochen werden!! ignore_user_abort(true); // Verarbeitung darf NICHT abgebrochen werden!!
// echo 'DEBUG: kritischer Bereich betreten<br>'; // echo 'DEBUG: kritischer Bereich betreten<br>';
} }
// Loesche alte Ressourcen // Loesche alte Ressourcen
mysql_query('DELETE FROM semaphore WHERE TIMESTAMPDIFF(MINUTE, zeit, now()) > 5 and ressource = \''.$ressource.'\''); mysql_query('DELETE FROM semaphore WHERE TIMESTAMPDIFF(MINUTE, zeit, now()) > 5 and ressource = \''.$resource.'\'');
$sql = 'INSERT INTO semaphore(ressource) values(\''.$ressource.'\')'; $sql = 'INSERT INTO semaphore(ressource) values(\''.$resource.'\')';
mysql_query($sql); mysql_query($sql);
if(mysql_affected_rows() > 0){ if(mysql_affected_rows() > 0){
// echo 'DEBUG: Semaphore fuer '.$ressource.' belegt!('.mysql_affected_rows().')<br>'; // echo 'DEBUG: Semaphore fuer '.$ressource.' belegt!('.mysql_affected_rows().')<br>';
@ -59,8 +59,8 @@ function semaphoreUP($resource){
} }
// @Returns TRUE if ok, FALSE on Semaphore error, NULL on MYQL Error // @Returns TRUE if ok, FALSE on Semaphore error, NULL on MYQL Error
function semaphoreDown($ressource){ function semaphoreDown($resource){
$sql = 'DELETE FROM semaphore where ressource = \''.$ressource.'\''; $sql = 'DELETE FROM semaphore where ressource = \''.$resource.'\'';
mysql_query($sql); mysql_query($sql);
if(mysql_affected_rows() == 0){ if(mysql_affected_rows() == 0){
// echo 'DEBUG: Semaphore '.$ressource.' war schon freigegeben<br>'; // echo 'DEBUG: Semaphore '.$ressource.' war schon freigegeben<br>';

Loading…
Cancel
Save