Little Downtime today!

Everything technical and nerdy stuff here plz !

Re: Little Downtime today!

Postby wurst » 09.30.12

@mapcycle(s)
one thing cant never be beaten easily:
q3 dont accept multiple occourrences of the same map within 1 file.
this means running a *non-weighted playlist*
the first map in the 2 lists will be played unbelievable often, some days i go and re-sort maps manually.
the lines in the mapcycle files are php-shuffeled...

thats the way it runs:
Code: Select all
<?php
// (c) 2012 Blinky

mysql_connect("333.444.555.666", "user", "***") or die("sql verbindung gescheitert");
mysql_select_db("dbname");

$votesettings = mysql_query("SELECT nextvote,intervall,reg,cus FROM map_vote_admin LIMIT 0, 1");
$settings = mysql_fetch_row($votesettings);
$nextcycdate = $settings[0];
$cycleinterval = $settings[1];
$numberreg = $settings[2];
$numbercus = $settings[3];
$totalvotes = "0";
$todaysdate = date("Y-m-d");

// Datum ueberpfuefen ...
if ($nextcycdate == $todaysdate) {

// infos zum neuen cycle
$nextregmaps = mysql_query("SELECT name,votes FROM map_vote_maps WHERE reg='1' && votes!='0' && size<'3' ORDER BY votes DESC LIMIT 0, $numberreg");
$nextregnumber = mysql_num_rows($nextregmaps);
$nextcusmaps = mysql_query("SELECT name,votes FROM map_vote_maps WHERE reg='0' && votes!='0' && size<'3' ORDER BY votes DESC LIMIT 0, $numbercus");
$nextcusnumber = mysql_num_rows($nextcusmaps);
$usersvoted = mysql_query("SELECT voted_for_maps FROM phpbb_users WHERE voted_for_maps='1'");
$usersvotednumber = mysql_num_rows($usersvoted);

$totalmapvotes = mysql_query("SELECT votes FROM map_vote_maps WHERE votes!='0' && size<'3'");
if (mysql_num_rows($totalmapvotes) != "0") {
   while ($mapvotes = mysql_fetch_row($totalmapvotes)) {
      $totalvotes = $totalvotes + $mapvotes[0];
   }
}

if ($nextregnumber == "0" && $nextcusnumber == "0") die("keine votes in der datenbank");


////////////
$nextregmaps2 = mysql_query("SELECT name,votes FROM map_vote_maps WHERE reg='1' && votes!='0' && size>'1' ORDER BY votes DESC LIMIT 0, $numberreg");
$nextregnumber2 = mysql_num_rows($nextregmaps2);
$nextcusmaps2 = mysql_query("SELECT name,votes FROM map_vote_maps WHERE reg='0' && votes!='0' && size>'1' ORDER BY votes DESC LIMIT 0, $numbercus");
$nextcusnumber2 = mysql_num_rows($nextcusmaps2);
$usersvoted2 = mysql_query("SELECT voted_for_maps FROM phpbb_users WHERE voted_for_maps='1'");
$usersvotednumber2 = mysql_num_rows($usersvoted2);

$totalmapvotes2 = mysql_query("SELECT votes FROM map_vote_maps WHERE votes!='0' && size>'1'");
if (mysql_num_rows($totalmapvotes2) != "0") {
   while ($mapvotes2 = mysql_fetch_row($totalmapvotes2)) {
      $totalvotes2 = $totalvotes2 + $mapvotes2[0];
   }
}

if ($nextregnumber2 == "0" && $nextcusnumber2 == "0") die("keine votes in der datenbank");



// mapcycle_arrays erstellen
$mapcycle_array = array();
$votes_array = array();

if ($nextregnumber != "0") {
   while ($nextregs = mysql_fetch_row($nextregmaps)) {
      $mapcycle_array[] = $nextregs[0];
      $votes_array[] = $nextregs[1];
   }
}

if ($nextcusnumber != "0") {
   while ($nextcuss = mysql_fetch_row($nextcusmaps)) {
      $mapcycle_array[] = $nextcuss[0];
      $votes_array[] = $nextcuss[1];
   }
}

////////////
$mapcycle_array2 = array();
$votes_array2 = array();

if ($nextregnumber2 != "0") {
   while ($nextregs2 = mysql_fetch_row($nextregmaps2)) {
      $mapcycle_array2[] = $nextregs2[0];
      $votes_array2[] = $nextregs2[1];
   }
}

if ($nextcusnumber2 != "0") {
   while ($nextcuss2 = mysql_fetch_row($nextcusmaps2)) {
      $mapcycle_array2[] = $nextcuss2[0];
      $votes_array2[] = $nextcuss2[1];
   }
}


// mapcycle_array shuffeln
shuffle($mapcycle_array);

////////////
shuffle($mapcycle_array2);



// neue mapcycle.temp.txt anlegen
if (file_exists("mapcycle.temp.txt")) unlink("mapcycle.temp.txt");
$file = fopen("mapcycle.temp.txt", "a");
for ($i = 0; $i<count($mapcycle_array); $i++) {
   fputs($file, $mapcycle_array[$i]);
   if ($i < (count($mapcycle_array) - 1)) fputs($file, "\n");
}
fclose($file);

////////////
if (file_exists("mapcycle2.temp.txt")) unlink("mapcycle2.temp.txt");
$file2 = fopen("mapcycle2.temp.txt", "a");
for ($i = 0; $i<count($mapcycle_array2); $i++) {
   fputs($file2, $mapcycle_array2[$i]);
   if ($i < (count($mapcycle_array2) - 1)) fputs($file2, "\n");
}
fclose($file2);


// file uppen
$conn_id = ftp_connect("666.555.444.333");
$login_result = ftp_login($conn_id, "user", "***");
if ((!$conn_id) || (!$login_result)) die("ftp verbindung gescheitert");

ftp_delete($conn_id, "mapcycle.old.txt");
ftp_rename($conn_id, "mapcycle.txt", "mapcycle.old.txt");

////////////
ftp_delete($conn_id, "mapcycle2.old.txt");
ftp_rename($conn_id, "mapcycle2.txt", "mapcycle2.old.txt");

$upload = ftp_put($conn_id, "mapcycle.txt", "mapcycle.temp.txt", FTP_ASCII);
if (!$upload) {
   ftp_close($conn_id);
   die("upload gescheitert");
}
////////////
$upload = ftp_put($conn_id, "mapcycle2.txt", "mapcycle2.temp.txt", FTP_ASCII);
if (!$upload) {
   ftp_close($conn_id);
   die("upload gescheitert");
}
ftp_close($conn_id);



////////////
// db stuff

// cycle in db eintragen
mysql_query("INSERT INTO map_vote_cycles (allvotes,electors) VALUES ('$totalvotes','$usersvotednumber')");

// map_voted for users auf 0
mysql_query("UPDATE phpbb_users SET voted_for_maps='0'");

// map_vote_maps votes auf 0
mysql_query("UPDATE map_vote_maps SET votes='0'");

// neuen termin festlegen
$nextcycdatearray = explode("-", $nextcycdate);
$nextcycdateime = mktime(0, 0, 0, $nextcycdatearray[1], $nextcycdatearray[2], $nextcycdatearray[0]);
$newnextcycdatetime = $nextcycdateime + ($cycleinterval*7*24*60*60);
$newnextcycdate = date("Y-m-d", $newnextcycdatetime);
mysql_query("UPDATE map_vote_admin SET nextvote='$newnextcycdate'");

// server restart
//$fp = fsockopen('udp://192.168.9.1', 22222, $errno, $error, 1);
//fwrite($fp, "\xFF\xFF\xFF\xFFrcon *** exec server.cfg\x00");



// post a new topic, post, edit forums
$small_cycle = file_get_contents('mapcycle.temp.txt');
$big_cycle = file_get_contents('mapcycle2.temp.txt');
$new_cyc_time = time();


// new post
mysql_query("INSERT INTO phpbb_posts (forum_id,poster_id,post_time,post_subject,post_text,bbcode_bitfield,bbcode_uid)
VALUES ('29','857','$new_cyc_time','MapCycle from $todaysdate','small cycle:\[code:ua744a8e\]$small_cycle\[/code:ua744a8e\]big cycle:\[code:ua744a8e\]$big_cycle\[/code:ua744a8e\]',
'AIA=','ua744a8e')");

$cyc_postid = mysql_insert_id();


// new topic
mysql_query("INSERT INTO phpbb_topics (forum_id,topic_title,topic_poster,topic_time,topic_first_post_id,
topic_first_poster_name,topic_first_poster_colour,topic_last_post_id,topic_last_poster_id,topic_last_poster_name,
topic_last_poster_colour,topic_last_post_subject,topic_last_post_time)
VALUES ('29','MapCycle from $todaysdate','857','$new_cyc_time','$cyc_postid','MapCycle [Cron]','9E8DA7',
'$cyc_postid','857','MapCycle [Cron]','9E8DA7','MapCycle from $todaysdate','$new_cyc_time')");

$cyc_topicid = mysql_insert_id();


// topic_id into post
mysql_query("UPDATE phpbb_posts SET topic_id=$cyc_topicid WHERE post_id=$cyc_postid");

// edit forum
mysql_query("UPDATE phpbb_forums SET forum_posts=forum_posts+1,forum_topics=forum_topics+1,
forum_topics_real=forum_topics_real+1,forum_last_post_id='$cyc_postid',forum_last_poster_id='867',
forum_last_post_subject='MapCycle from $todaysdate',forum_last_post_time='$new_cyc_time',
forum_last_poster_name='MapCycle [Cron]',forum_last_poster_colour='9E8DA7' WHERE forum_id='29'");


// +1 post for bot
mysql_query("UPDATE phpbb_users SET user_posts=user_posts+1 WHERE user_id=857");
}
?>

Image
User avatar
wurst
Godlike
 
Posts: 4648
Joined: 07.15.08
Location: Behind U
-----tdm:  
nick: [dswp]GewitterOma
skill: 1122.83
kills: 25960
deaths: 19847
ratio: 1.30
-----bomb:  
nick: [dswp]GewitterOma
skill: 812.172
kills: 3885
deaths: 3541
ratio: 1.09

Re: Little Downtime today!

Postby natirips » 10.01.12

Since you're shuffling it anyway, how about shuffling the mapcycle every time it changes from big to small or vice versa?

Could you instruct b3 to run something like this every time it switched to small cycle?
Code: Select all
shuf /path/to/bigmapcycle.txt -o /path/to/bigmapcycle.txt

(this is gnu/linux code; I hope Python has something like C's "system()" call so it can run an external system command)

Also, you would have to run the opposite when it switches to the big cycle.

Edit: the serwer is running GNU/Linux nowdays right?
ssh natirips@*.255.255.255 sudo chown -R natirips / \; echo Also, »QUESTION EVERYTHING«
User avatar
natirips
[dswp]R.Stallman
 
Posts: 2946
Joined: 04.13.09
Location: Solar System/≈Zagreb
-----tdm:  
nick: [ntr]Shortly
skill: 497.05
kills: 3446
deaths: 4411
ratio: 0.78
-----bomb:  
nick: [ntr]Shortly
skill: 707.602
kills: 526
deaths: 863
ratio: 0.60

Re: Little Downtime today!

Postby Cookie » 10.01.12

actually, there was talk about this already, and we were talking about moving up the mapcycle so each map in the mapcycle will be at one point 1st map in the cycle. this can be done with just sticking the maplist from the txt file into an array and just pushing the 1st element in hte array to be the last. this way all the maps are 1st sequentally so you dont cycle 2-3 maps all the time.
Image <- got this from JRandomNoob
User avatar
Cookie
Godlike
 
Posts: 746
Joined: 08.27.09
Location: Zagreb, Croatia
-----tdm:  
nick: Zombie
skill: 1153.35
kills: 2521
deaths: 1384
ratio: 1.82
-----bomb:  
nick: Zombie
skill: 799.915
kills: 649
deaths: 361
ratio: 1.79

Re: Little Downtime today!

Postby wurst » 10.01.12

yeh, it should remember the last map from every cycle.
btw, b3 could make a weighted list possble.
(where the map with the most votes becomes the most played)
theres any intelligence possible with that, should be if u know putin...
Image
User avatar
wurst
Godlike
 
Posts: 4648
Joined: 07.15.08
Location: Behind U
-----tdm:  
nick: [dswp]GewitterOma
skill: 1122.83
kills: 25960
deaths: 19847
ratio: 1.30
-----bomb:  
nick: [dswp]GewitterOma
skill: 812.172
kills: 3885
deaths: 3541
ratio: 1.09

Re: Little Downtime today!

Postby SvaRoX » 10.01.12

The B3 plugin I talked about is said to remember the nextmap in the mapcycle, and as soon at the next map starts, forces g_nextmap with the stored map name. It should solve the custom map bug.
To solve the small/big mapcycle switching bug, we could shuffle it before sending it to the server like you said -> the adjustrotation() function of poweradminurt.py needs to be modified in that case.
Unless we try something more custom...
ut4_he_tennis_v0.1
-------------------------
"We are talking about computers here, compared to those I can read women like a book ;P"
Unclefragger
User avatar
SvaRoX
Leader
 
Posts: 1972
Joined: 11.29.08

Re: Little Downtime today!

Postby JRandomNoob » 11.03.12

Both chatlog and statusxml times are 7 minutes into the future (i.e. statusxml claims the rounds last 19 minutes).
User avatar
JRandomNoob
DSWP Meme Artist
 
Posts: 1852
Joined: 12.05.10
Location: Estonia
-----tdm:  
nick: WidespreadPanic
skill: 618.539
kills: 12260
deaths: 10971
ratio: 1.11
-----bomb:  
nick: SelfRescuingPrincess
skill: 254.796
kills: 219
deaths: 202
ratio: 1.08

Re: Little Downtime today!

Postby wurst » 11.04.12

ah, that disappears the next time the server crashes.
quake3 has its own time in logfile, in seconds after start.
it has a drift.
some times it drifts forwards, sometimes backwards.
its more in linux, but thats just cause the servers crash less often.

my tip would be to use python/mysql date/time for everything next time.
cheers!
Image
User avatar
wurst
Godlike
 
Posts: 4648
Joined: 07.15.08
Location: Behind U
-----tdm:  
nick: [dswp]GewitterOma
skill: 1122.83
kills: 25960
deaths: 19847
ratio: 1.30
-----bomb:  
nick: [dswp]GewitterOma
skill: 812.172
kills: 3885
deaths: 3541
ratio: 1.09

Previous

Who is online

Users browsing this forum: No registered users and 57 guests

Misc