Commit cdf9f488 authored by nanahira's avatar nanahira

set seed from argv

parent e7257b53
......@@ -25,6 +25,7 @@ Game* mainGame;
#ifdef YGOPRO_SERVER_MODE
unsigned short aServerPort;
unsigned short replay_mode;
time_t pre_seed[3];
HostInfo game_info;
void Game::MainServerLoop() {
......
......@@ -557,8 +557,8 @@ extern Game* mainGame;
extern unsigned short aServerPort;
extern unsigned short replay_mode;
extern HostInfo game_info;
extern time_t pre_seed[3];
#endif
}
#define CARD_IMG_WIDTH 177
......
......@@ -73,7 +73,9 @@ int main(int argc, char* argv[]) {
ygo::game_info.no_shuffle_deck = false;
ygo::game_info.duel_rule = DEFAULT_DUEL_RULE;
ygo::game_info.time_limit = 180;
if(argc > 1) {
for (int i = 0; i < 3; ++i)
ygo::pre_seed[i] = (time_t)0;
if (argc > 1) {
ygo::aServerPort = atoi(argv[1]);
int lflist = atoi(argv[2]);
if(lflist < 0)
......@@ -108,6 +110,10 @@ int main(int argc, char* argv[]) {
ygo::game_info.draw_count = atoi(argv[10]);
ygo::game_info.time_limit = atoi(argv[11]);
ygo::replay_mode = atoi(argv[12]);
for (int i = 13; (i < argc && i <= 15) ; ++i)
{
ygo::pre_seed[i - 13] = (time_t)atoi(argv[i]);
}
}
ygo::mainGame = &_game;
ygo::mainGame->MainServerLoop();
......
......@@ -535,6 +535,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
rh.version = PRO_VERSION;
rh.flag = 0;
time_t seed = time(0);
#ifdef YGOPRO_SERVER_MODE
if(pre_seed[duel_count] > 0) {
seed = pre_seed[duel_count];
}
#endif
rh.seed = seed;
last_replay.BeginRecord();
last_replay.WriteHeader(rh);
......
......@@ -504,6 +504,11 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
rh.flag = REPLAY_TAG;
time_t seed = time(0);
rh.seed = seed;
#ifdef YGOPRO_SERVER_MODE
if(pre_seed[0] > 0) {
seed = pre_seed[0];
}
#endif
last_replay.BeginRecord();
last_replay.WriteHeader(rh);
rnd.reset(seed);
......
Subproject commit 80f1ced5a185d25d6a421f71a28caacc04e564f2
Subproject commit d8ee620789d02a1a540f5bd788971268870a72ab
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment