Преглед на файлове

Replaced some final uses of rand()
* Replaced some final left overs of rand() with rnd() from MT19937AR.

aleos89 преди 8 години
родител
ревизия
20908ee9c0
променени са 2 файла, в които са добавени 5 реда и са изтрити 4 реда
  1. 3 2
      src/char/char.cpp
  2. 2 2
      src/map/skill.c

+ 3 - 2
src/char/char.cpp

@@ -15,6 +15,7 @@
 #include "../common/malloc.h"
 #include "../common/mapindex.h"
 #include "../common/mmo.h"
+#include "../common/random.h"
 #include "../common/showmsg.h"
 #include "../common/socket.h"
 #include "../common/strlib.h"
@@ -1379,7 +1380,7 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i
 	struct point tmp_start_point[MAX_STARTPOINT];
 	struct startitem tmp_start_items[MAX_STARTITEM];
 	uint32 char_id;
-	int flag, k, start_point_idx = rand() % charserv_config.start_point_count;
+	int flag, k, start_point_idx = rnd() % charserv_config.start_point_count;
 
 	safestrncpy(name, name_, NAME_LENGTH);
 	normalize_name(name,TRIM_CHARS);
@@ -1453,7 +1454,7 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i
 		memset(tmp_start_items, 0, MAX_STARTITEM * sizeof(struct startitem));
 		memcpy(tmp_start_point, charserv_config.start_point_doram, MAX_STARTPOINT * sizeof(struct point));
 		memcpy(tmp_start_items, charserv_config.start_items_doram, MAX_STARTITEM * sizeof(struct startitem));
-		start_point_idx = rand() % charserv_config.start_point_count_doram;
+		start_point_idx = rnd() % charserv_config.start_point_count_doram;
 	}
 #endif
 

+ 2 - 2
src/map/skill.c

@@ -4365,11 +4365,11 @@ static int skill_tarotcard(struct block_list* src, struct block_list *target, ui
 
 	if (battle_config.tarotcard_equal_chance) {
 		//eAthena equal chances
-		card = rand() % 14 + 1;
+		card = rnd() % 14 + 1;
 	}
 	else {
 		//Official chances
-		int rate = rand() % 100;
+		int rate = rnd() % 100;
 		if (rate < 10) card = 1; // THE FOOL
 		else if (rate < 20) card = 2; // THE MAGICIAN
 		else if (rate < 30) card = 3; // THE HIGH PRIESTESS