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];
@ -593,6 +593,17 @@ function joinChallenge($clan_challenge_id, array $user, $charid, $slot ) {
} }
if($char['status'] != 'Frei') { if($char['status'] != 'Frei') {
if($forced && ($char['status'] == 'Kampf' || $char['status'] == 'Schatz Suche')) { // foreign assignment may also possible if the status is in "fetching" state
// okay now check if the fetch-time is reached!!
if($char['status'] == 'Schatz Suche') {
$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? // char is not free but is he already participating?
$participant = getParticipatingChar($clan_challenge_id, $clan['id'], $charid); $participant = getParticipatingChar($clan_challenge_id, $clan['id'], $charid);
if(!$participant || !$participant['forced']) { if(!$participant || !$participant['forced']) {
@ -601,6 +612,7 @@ function joinChallenge($clan_challenge_id, array $user, $charid, $slot ) {
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); 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; return NULL;
} }
}
$clan_challenge = getChallenge($clan_challenge_id); $clan_challenge = getChallenge($clan_challenge_id);
@ -780,7 +792,7 @@ 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!';
@ -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