ULTIMA8: Move std/ folder into shared/std/

This commit is contained in:
Paul Gilbert 2019-12-16 22:00:28 -08:00 committed by Paul Gilbert
parent 34a387472c
commit c236d83295
93 changed files with 196 additions and 213 deletions

View File

@ -1,7 +1,9 @@
MODULE := engines/ultima
MODULE_OBJS := \
detection.o
detection.o \
shared/std/misc.o \
shared/std/string.o
ifdef ENABLE_ULTIMA8
MODULE_OBJS += \
@ -174,8 +176,6 @@ MODULE_OBJS += \
ultima8/misc/pent_include.o \
ultima8/misc/util.o \
ultima8/misc/version.o \
ultima8/std/misc.o \
ultima8/std/string.o \
ultima8/usecode/bit_set.o \
ultima8/usecode/uc_list.o \
ultima8/usecode/uc_machine.o \

View File

@ -20,8 +20,8 @@
*
*/
#ifndef ULTIMA8_STD_CONTAINERS_H
#define ULTIMA8_STD_CONTAINERS_H
#ifndef ULTIMA_STD_CONTAINERS_H
#define ULTIMA_STD_CONTAINERS_H
#include "common/algorithm.h"
#include "common/array.h"
@ -31,7 +31,6 @@
#include "common/stack.h"
namespace Ultima {
namespace Ultima8 {
namespace std {
template<class T>
@ -262,7 +261,6 @@ protected:
};
} // End of namespace std
} // End of namespace Ultima8
} // End of namespace Ultima
#endif

View File

@ -20,12 +20,10 @@
*
*/
#include "ultima/ultima8/std/misc.h"
#include "ultima/ultima8/ultima8.h"
#include "ultima/shared/std/misc.h"
#include "common/algorithm.h"
namespace Ultima {
namespace Ultima8 {
namespace std {
void memset(void *data, byte val, size_t count) {
@ -76,10 +74,6 @@ double atof(const char *str) {
return ::atof(str);
}
uint rand() {
return Ultima8Engine::get_instance()->getRandomNumber(0x7fffffff);
}
double sqrt(double val) {
return ::sqrt(val);
}
@ -106,5 +100,4 @@ void free(void *&p) {
}
} // End of namespace std
} // End of namespace Ultima8
} // End of namespace Ultima

View File

@ -26,9 +26,10 @@
#include "common/scummsys.h"
namespace Ultima {
namespace Ultima8 {
namespace std {
enum Precision { hex = 16, dec = 10 };
template<class T1, class T2>
struct pair {
T1 first;
@ -49,20 +50,13 @@ extern int atoi(const char *str);
extern double atof(const char *str);
extern const char *strstr(const char *str, const char *substr);
extern double pow(double x, double y);
#ifdef rand
#undef rand
#endif
extern uint rand();
extern double sqrt(double val);
extern void *malloc(size_t size);
extern void *calloc(size_t num, size_t size);
extern void free(void *&p);
} // End of namespace std
} // End of namespace Ultima8
} // End of namespace Ultima
#endif

View File

@ -20,11 +20,10 @@
*
*/
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "common/algorithm.h"
namespace Ultima {
namespace Ultima8 {
namespace std {
const char *const endl = "\n";
@ -147,5 +146,4 @@ void string::resize(size_t count) {
}
} // End of namespace std
} // End of namespace Ultima8
} // End of namespace Ultima

View File

@ -20,13 +20,12 @@
*
*/
#ifndef ULTIMA8_STD_STRING_H
#define ULTIMA8_STD_STRING_H
#ifndef ULTIMA_STD_STRING_H
#define ULTIMA_STD_STRING_H
#include "common/str.h"
namespace Ultima {
namespace Ultima8 {
namespace std {
class string : public Common::String {
@ -193,7 +192,6 @@ public:
extern const char *const endl;
} // End of namespace std
} // End of namespace Ultima8
} // End of namespace Ultima
#endif

View File

@ -25,8 +25,8 @@
#include "ultima/ultima8/kernel/process.h"
#include "ultima/ultima8/usecode/intrinsics.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/string.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -26,7 +26,7 @@
#ifdef USE_ALSA_MIDI
#include <alsa/asoundlib.h>
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "ultima/ultima8/audio/midi/low_level_midi_driver.h"
namespace Ultima {

View File

@ -447,7 +447,7 @@ inline void OPL_CALC_CH(OPL_CH *CH) {
#define WHITE_NOISE_db 6.0
inline void OPL_CALC_RH(OPL_CH *CH) {
uint32 env_tam, env_sd, env_top, env_hh;
int whitenoise = int((std::rand() & 1) * (WHITE_NOISE_db / EG_STEP));
int whitenoise = int((getRandom() & 1) * (WHITE_NOISE_db / EG_STEP));
int tone8;
OPL_SLOT *SLOT;

View File

@ -25,7 +25,7 @@
#include "ultima/ultima8/audio/midi/midi_driver.h"
#include "ultima/ultima8/audio/midi/xmidi_sequence_handler.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "common/mutex.h"
namespace Ultima {

View File

@ -22,7 +22,7 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/audio/midi/midi_driver.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/audio/midi/midi_driver.h"
#include "ultima/ultima8/audio/midi/windows_midi_driver.h"

View File

@ -28,7 +28,7 @@
#define USE_UNIX_SEQ_MIDI
#include "ultima/ultima8/audio/midi/low_level_midi_driver.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -24,7 +24,7 @@
#define ULTIMA8_AUDIO_SPEECHFLEX_H
#include "ultima/ultima8/audio/sound_flex.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -19,9 +19,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef ULTIMA8_CONF_CONFIGFILEMANAGER_H
#define ULTIMA8_CONF_CONFIGFILEMANAGER_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "ultima/ultima8/misc/istring.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/conf/ini_file.h"
namespace Ultima {

View File

@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef ULTIMA8_CONF_INIFILE_H
#define ULTIMA8_CONF_INIFILE_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -25,9 +25,9 @@
#include "ultima/ultima8/conf/config_file_manager.h"
#include "ultima/ultima8/misc/istring.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/string.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,8 +23,8 @@
#ifndef ULTIMA8_FILESYS_ARCHIVE_H
#define ULTIMA8_FILESYS_ARCHIVE_H
#include "ultima/ultima8/std/string.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/string.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_FILESYS_ARCHIVEFILE_H
#define ULTIMA8_FILESYS_ARCHIVEFILE_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -25,7 +25,7 @@
#include "ultima/ultima8/filesys/named_archive_file.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -22,7 +22,7 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "ultima/ultima8/ultima8.h"
#include "common/system.h"
#include "common/memstream.h"

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_FILESYS_FILESYSTEM_H
#define ULTIMA8_FILESYS_FILESYSTEM_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/filesys/odata_source.h"
#include "common/file.h"

View File

@ -24,7 +24,7 @@
#define ULTIMA8_FILESYS_IDATASOURCE_H
#include "common/file.h"
#include "ultima/ultima8/std/misc.h"
#include "ultima/shared/std/misc.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_FILESYS_LISTFILES_H
#define ULTIMA8_FILESYS_LISTFILES_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "ultima/ultima8/filesys/file_system.h"
namespace Ultima {

View File

@ -25,7 +25,7 @@
#include "ultima/ultima8/misc/common_types.h"
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "common/stream.h"
#include "common/algorithm.h"

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_FILESYS_OUTPUTLOGGER_H
#define ULTIMA8_FILESYS_OUTPUTLOGGER_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "common/stream.h"
namespace Ultima {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_FILESYS_SAVEGAME_H
#define ULTIMA8_FILESYS_SAVEGAME_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
#include "common/hashmap.h"
#include "common/serializer.h"
#include "engines/metaengine.h"

View File

@ -24,7 +24,7 @@
#define ULTIMA8_FILESYS_U8SAVEFILE_H
#include "ultima/ultima8/filesys/named_archive_file.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GAMES_GAMEDATA_H
#define ULTIMA8_GAMES_GAMEDATA_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/graphics/frame_id.h"
namespace Ultima {

View File

@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ULTIMA8_GAMES_TREASURELOADER_H
#include "ultima/ultima8/world/actors/treasure_info.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_ANIMDAT_H
#define ULTIMA8_GRAPHICS_ANIMDAT_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_FONTS_FIXEDWIDTHFONT_H
#define ULTIMA8_GRAPHICS_FONTS_FIXEDWIDTHFONT_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_FONTS_FONT_H
#define ULTIMA8_GRAPHICS_FONTS_FONT_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/rect.h"
#include "ultima/ultima8/misc/encoding.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_FONTS_FONTMANAGER_H
#define ULTIMA8_GRAPHICS_FONTS_FONTMANAGER_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "graphics/font.h"
namespace Ultima {

View File

@ -24,7 +24,7 @@
#define ULTIMA8_GRAPHICS_PALETTEMANAGER_H
#include "ultima/ultima8/graphics/palette.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_SCALERMANAGER_H
#define ULTIMA8_GRAPHICS_SCALERMANAGER_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/istring.h"
namespace Ultima {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_SHAPE_H
#define ULTIMA8_GRAPHICS_SHAPE_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_SKFPlayer_H
#define ULTIMA8_GRAPHICS_SKFPlayer_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_GRAPHICS_TYPEFLAGS_H
#define ULTIMA8_GRAPHICS_TYPEFLAGS_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/graphics/shape_info.h"
namespace Ultima {

View File

@ -99,8 +99,8 @@ void ContainerGump::getItemCoords(Item *item, int32 &itemx, int32 &itemy) {
// randomize position
// TODO: maybe try to put it somewhere where it doesn't overlap others?
itemx = std::rand() % itemarea.w;
itemy = std::rand() % itemarea.h;
itemx = getRandom() % itemarea.w;
itemy = getRandom() % itemarea.h;
item->setGumpLocation(itemx, itemy);
}

View File

@ -534,8 +534,8 @@ void GameMapGump::DropItem(Item *item, int mx, int my) {
ty = dragging_pos[1];
int inaccuracy = 4 * (30 - avatar->getDex());
if (inaccuracy < 20) inaccuracy = 20; // just in case dex > 25
tx += (std::rand() % inaccuracy) - (std::rand() % inaccuracy);
ty += (std::rand() % inaccuracy) - (std::rand() % inaccuracy);
tx += (getRandom() % inaccuracy) - (getRandom() % inaccuracy);
ty += (getRandom() % inaccuracy) - (getRandom() % inaccuracy);
MissileTracker t(item, tx, ty, dragging_pos[2],
speed, 4);
t.launchItem();

View File

@ -24,7 +24,7 @@
#define ULTIMA8_GUMPS_GAMEMAPGUMP_H
#include "ultima/ultima8/gumps/gump.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -26,7 +26,7 @@
#include "ultima/ultima8/kernel/object.h"
#include "ultima/ultima8/misc/rect.h"
#include "ultima/ultima8/graphics/frame_id.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -24,7 +24,7 @@
#define ULTIMA8_GUMPS_INVERTERGUMP_H
#include "ultima/ultima8/gumps/desktop_gump.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -26,7 +26,7 @@
#include "ultima/ultima8/gumps/modal_gump.h"
#include "ultima/ultima8/usecode/intrinsics.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -24,7 +24,7 @@
#define ULTIMA8_GUMPS_ScalerGump_H
#include "ultima/ultima8/gumps/desktop_gump.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -25,7 +25,7 @@
#include "ultima/ultima8/gumps/modal_gump.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -29,7 +29,7 @@
#include "ultima/ultima8/misc/args.h"
#include "ultima/ultima8/games/game_info.h"
#include "ultima/ultima8/games/game_detector.h"
#include "ultima/ultima8/std/misc.h"
#include "ultima/shared/std/misc.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -25,7 +25,7 @@
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/filesys/odata_source.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_KERNEL_HIDMANAGER_H
#define ULTIMA8_KERNEL_HIDMANAGER_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/kernel/hid_keys.h"
#include "ultima/ultima8/kernel/joystick.h"
//#include "SDL_events.h"

View File

@ -23,7 +23,7 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/kernel/joystick.h"
#include "ultima/ultima8/ultima8.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
//#include "SDL_timer.h"
//#include "SDL_events.h"

View File

@ -21,14 +21,13 @@
*/
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/kernel/kernel.h"
#include "ultima/ultima8/kernel/process.h"
#include "ultima/ultima8/misc/id_man.h"
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/filesys/odata_source.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/ultima8.h"
namespace Ultima {
namespace Ultima8 {
@ -455,5 +454,9 @@ uint32 Kernel::I_resetRef(const uint8 *args, unsigned int /*argsize*/) {
return 0;
}
uint getRandom() {
return Ultima8Engine::get_instance()->getRandomNumber(0x7fffffff);
}
} // End of namespace Ultima8
} // End of namespace Ultima

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_KERNEL_KERNEL_H
#define ULTIMA8_KERNEL_KERNEL_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/usecode/intrinsics.h"
namespace Ultima {
@ -172,6 +172,9 @@ struct ProcessLoader {
}
};
extern uint getRandom();
} // End of namespace Ultima8
} // End of namespace Ultima

View File

@ -22,7 +22,7 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/kernel/object_manager.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/id_man.h"
#include "ultima/ultima8/kernel/object.h"
#include "ultima/ultima8/world/item.h"

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_KERNEL_OBJECTMANAGER_H
#define ULTIMA8_KERNEL_OBJECTMANAGER_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_KERNEL_USECODE_PROCESS_H
#define ULTIMA8_KERNEL_USECODE_PROCESS_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -25,7 +25,7 @@
#include "ultima/ultima8/kernel/allocator.h"
#include "ultima/ultima8/kernel/segmented_pool.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"
namespace Ultima {

View File

@ -24,8 +24,8 @@
// but it suffices quite well at the moment.
#include "ultima/ultima8/misc/common_types.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ultima/ultima8/graphics/render_surface.h"
#include "ultima/ultima8/misc/util.h"
#include "ultima/ultima8/graphics/fonts/fixed_width_font.h"
#include "ultima/ultima8/std/misc.h"
#include "ultima/shared/std/misc.h"
#include "common/file.h"
#include "common/debug.h"

View File

@ -24,7 +24,8 @@
#define ULTIMA8_MISC_CONSOLE_H
#include "ultima/ultima8/misc/istring.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/misc.h"
#include "common/debug.h"
#include "common/hashmap.h"
#include "common/file.h"
@ -401,10 +402,6 @@ public:
};
*/
namespace std {
enum Precision { hex = 16, dec = 10 };
}
class ConsoleStream : public Common::WriteStream {
private:
std::Precision _precision;

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_MISC_IDMAN_H
#define ULTIMA8_MISC_IDMAN_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef ULTIMA8_MISC_ISTRING_H
#define ULTIMA8_MISC_ISTRING_H
#include "ultima/ultima8/std/misc.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/misc.h"
#include "ultima/shared/std/string.h"
#include "common/array.h"
#ifdef strcasecmp

View File

@ -40,7 +40,7 @@
//
// Strings
//
//#include "ultima/ultima8/std/string.h"
//#include "ultima/shared/std/string.h"
//#include <cstring>
//#include <cstdlib>
#include "ultima/ultima8/misc/istring.h"
@ -143,8 +143,8 @@ void setAllocationFunctions(allocFunc a, deallocFunc d);
// C Standard Library and STL
#include <fstream>
#include <cstdio>
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/containers.h"
// Useful Pentagram headers
#include "ultima/ultima8/world/get_object.h"

View File

@ -23,7 +23,7 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/misc/util.h"
#include "ultima/ultima8/misc/istring.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef ULTIMA8_MISC_UTIL_H
#define ULTIMA8_MISC_UTIL_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/misc.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/misc.h"
#include "ultima/ultima8/misc/istring.h"
namespace Ultima {

View File

@ -33,7 +33,7 @@
#include "engines/engine.h"
#include "graphics/surface.h"
#include "ultima/detection.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/usecode/intrinsics.h"
#include "ultima/ultima8/misc/args.h"

View File

@ -23,8 +23,8 @@
#ifndef ULTIMA8_USECODE_UCLIST_H
#define ULTIMA8_USECODE_UCLIST_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -2344,7 +2344,7 @@ uint32 UCMachine::I_urandom(const uint8 *args, unsigned int /*argsize*/) {
// return random integer between 0 (incl.) to num (excl.)
return (std::rand() % num);
return (getRandom() % num);
}
uint32 UCMachine::I_rndRange(const uint8 *args, unsigned int /*argsize*/) {
@ -2355,7 +2355,7 @@ uint32 UCMachine::I_rndRange(const uint8 *args, unsigned int /*argsize*/) {
if (hi <= lo) return lo;
return (lo + (std::rand() % (hi - lo + 1)));
return (lo + (getRandom() % (hi - lo + 1)));
}

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_USECODE_UCMACHINE_H
#define ULTIMA8_USECODE_UCMACHINE_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/usecode/intrinsics.h"
namespace Ultima {

View File

@ -22,7 +22,7 @@
#ifndef ULTIMA8_USECODE_UCPROCESS_H
#define ULTIMA8_USECODE_UCPROCESS_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/kernel/process.h"
#include "ultima/ultima8/usecode/uc_stack.h"

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_USECODE_USECODE_H
#define ULTIMA8_USECODE_USECODE_H
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -107,14 +107,14 @@ bool Actor::loadMonsterStats() {
if (mi->max_hp <= mi->min_hp)
hp = mi->min_hp;
else
hp = mi->min_hp + std::rand() % (mi->max_hp - mi->min_hp);
hp = mi->min_hp + getRandom() % (mi->max_hp - mi->min_hp);
setHP(hp);
uint16 dex;
if (mi->max_dex <= mi->min_dex)
dex = mi->min_dex;
else
dex = mi->min_dex + std::rand() % (mi->max_dex - mi->min_dex);
dex = mi->min_dex + getRandom() % (mi->max_dex - mi->min_dex);
setDex(dex);
uint8 new_alignment = mi->alignment;
@ -147,7 +147,7 @@ bool Actor::giveTreasure() {
// check chance
if (ti.chance < 0.999 &&
(static_cast<double>(std::rand()) / RAND_MAX) > ti.chance) {
(static_cast<double>(getRandom()) / RAND_MAX) > ti.chance) {
continue;
}
@ -156,7 +156,7 @@ bool Actor::giveTreasure() {
if (ti.mincount >= ti.maxcount)
count = ti.mincount;
else
count = ti.mincount + (std::rand() % (ti.maxcount - ti.mincount));
count = ti.mincount + (getRandom() % (ti.maxcount - ti.mincount));
if (!ti.special.empty()) {
if (ti.special == "weapon") {
@ -169,7 +169,7 @@ bool Actor::giveTreasure() {
int chance = si->weaponinfo->treasure_chance;
if (!chance) continue;
int r = std::rand() % 100;
int r = getRandom() % 100;
#if 0
pout << "weapon (" << s << ") chance: " << r << "/"
<< chance << std::endl;
@ -194,13 +194,13 @@ bool Actor::giveTreasure() {
int frameNum;
uint16 qualityNum;
if (std::rand() % 10 < 8) {
if (getRandom() % 10 < 8) {
// wand
if (std::rand() % 10 < 4) {
if (getRandom() % 10 < 4) {
// charged
frameNum = 0;
qualityNum = 3 + (std::rand() % 4) + // charges
((1 + (std::rand() % 4)) << 8); // spell
qualityNum = 3 + (getRandom() % 4) + // charges
((1 + (getRandom() % 4)) << 8); // spell
} else {
frameNum = 15;
qualityNum = 0;
@ -213,13 +213,13 @@ bool Actor::giveTreasure() {
item->randomGumpLocation();
}
if (std::rand() % 10 < 6) {
if (getRandom() % 10 < 6) {
// rod
if (std::rand() % 10 < 2) {
if (getRandom() % 10 < 2) {
// charged
frameNum = 3;
qualityNum = 3 + (std::rand() % 4) + // charges
((1 + (std::rand() % 7)) << 8); // spell
qualityNum = 3 + (getRandom() % 4) + // charges
((1 + (getRandom() % 7)) << 8); // spell
} else {
frameNum = 16;
qualityNum = 0;
@ -232,15 +232,15 @@ bool Actor::giveTreasure() {
item->randomGumpLocation();
}
if (std::rand() % 10 < 5) {
if (getRandom() % 10 < 5) {
// symbol
if (std::rand() % 10 < 5) {
if (getRandom() % 10 < 5) {
// charged
frameNum = 12;
uint8 spell = 1 + (std::rand() % 11);
uint8 spell = 1 + (getRandom() % 11);
qualityNum = spell << 8;
if (spell < 4) {
qualityNum += 3 + (std::rand() % 4);
qualityNum += 3 + (getRandom() % 4);
} else {
// symbol can only have one charge of anything
// other than ignite/extinguish
@ -258,13 +258,13 @@ bool Actor::giveTreasure() {
item->randomGumpLocation();
}
if (std::rand() % 10 < 2) {
if (getRandom() % 10 < 2) {
// demon talisman
if (std::rand() % 10 < 2) {
if (getRandom() % 10 < 2) {
// charged
frameNum = 9;
qualityNum = 1 + (std::rand() % 2) + // charges
((10 + (std::rand() % 2)) << 8); // spell
qualityNum = 1 + (getRandom() % 2) + // charges
((10 + (getRandom() % 2)) << 8); // spell
} else {
frameNum = 18;
qualityNum = 0;
@ -319,11 +319,11 @@ bool Actor::giveTreasure() {
// we need to produce a number of items
for (i = 0; (int)i < count; ++i) {
// pick shape
int n = std::rand() % ti.shapes.size();
int n = getRandom() % ti.shapes.size();
uint32 shapeNum = ti.shapes[n];
// pick frame
n = std::rand() % ti.frames.size();
n = getRandom() % ti.frames.size();
uint32 frameNum = ti.frames[n];
ShapeInfo *si = GameData::get_instance()->getMainShapes()->
@ -576,7 +576,7 @@ int Actor::getDamageAmount() {
int min = static_cast<int>(si->monsterinfo->min_dmg);
int max = static_cast<int>(si->monsterinfo->max_dmg);
int damage = (std::rand() % (max - min + 1)) + min;
int damage = (getRandom() % (max - min + 1)) + min;
return damage;
} else {
@ -628,7 +628,7 @@ void Actor::receiveHit(uint16 other, int dir, int damage, uint16 damage_type) {
int32 xv, yv, zv;
getLocation(xv, yv, zv);
zv += (std::rand() % 24);
zv += (getRandom() % 24);
Process *sp = new SpriteProcess(620, start, end, 1, 1, xv, yv, zv);
Kernel::get_instance()->addProcess(sp);
}
@ -681,9 +681,9 @@ void Actor::receiveHit(uint16 other, int dir, int damage, uint16 damage_type) {
int sfx;
if (damage)
sfx = 50 + (std::rand() % 2); // constants!
sfx = 50 + (getRandom() % 2); // constants!
else
sfx = 20 + (std::rand() % 3); // constants!
sfx = 20 + (getRandom() % 3); // constants!
AudioProcess *audioproc = AudioProcess::get_instance();
if (audioproc) audioproc->playSFX(sfx, 0x60, objid, 0);
return;
@ -763,7 +763,7 @@ ProcId Actor::die(uint16 damageType) {
pout << "Actor::die: scheduling resurrection" << std::endl;
int timeout = ((std::rand() % 25) + 5) * 30; // 5-30 seconds
int timeout = ((getRandom() % 25) + 5) * 30; // 5-30 seconds
Process *resproc = new ResurrectionProcess(this);
Kernel::get_instance()->addProcess(resproc);
@ -792,19 +792,19 @@ ProcId Actor::die(uint16 damageType) {
for (int i = 0; i < count; ++i) {
Item *piece = ItemFactory::createItem(mi->explode,
std::rand() % framecount,
getRandom() % framecount,
0, // qual
Item::FLG_FAST_ONLY, //flags,
0, // npcnum
0, // mapnum
0, true // ext. flags, objid
);
piece->move(x - 128 + 32 * (std::rand() % 6),
y - 128 + 32 * (std::rand() % 6),
z + std::rand() % 8); // move to near actor's position
piece->hurl(-25 + (std::rand() % 50),
-25 + (std::rand() % 50),
10 + (std::rand() % 10),
piece->move(x - 128 + 32 * (getRandom() % 6),
y - 128 + 32 * (getRandom() % 6),
z + getRandom() % 8); // move to near actor's position
piece->hurl(-25 + (getRandom() % 50),
-25 + (getRandom() % 50),
10 + (getRandom() % 10),
4); // (wrong?) CONSTANTS!
}
}
@ -891,7 +891,7 @@ int Actor::calculateAttackDamage(uint16 other, int damage, uint16 damage_type) {
// special attacks
if (damage && damage_type) {
if (damage_type & WeaponInfo::DMG_SLAYER) {
if (std::rand() % 10 == 0) {
if (getRandom() % 10 == 0) {
slayer = true;
damage = 255; // instant kill
}
@ -945,7 +945,7 @@ int Actor::calculateAttackDamage(uint16 other, int damage, uint16 damage_type) {
if (defenddex <= 0) defenddex = 1;
if ((getActorFlags() & ACT_STUNNED) ||
(rand() % (attackdex + 3) > rand() % defenddex)) {
(getRandom() % (attackdex + 3) > getRandom() % defenddex)) {
hit = true;
}

View File

@ -23,7 +23,7 @@
#ifndef WORLD_ACTORS_ACTORANIM_H
#define WORLD_ACTORS_ACTORANIM_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/world/actors/anim_action.h"
namespace Ultima {

View File

@ -364,7 +364,7 @@ void ActorAnimProcess::doSpecial() {
if (item_num == 1 && (action == Animation::readyWeapon ||
action == Animation::unreadyWeapon) &&
a->getEquip(ShapeInfo::SE_WEAPON) != 0) {
int sfx = (std::rand() % 2) ? 0x51 : 0x52; // constants!
int sfx = (getRandom() % 2) ? 0x51 : 0x52; // constants!
AudioProcess *audioproc = AudioProcess::get_instance();
if (audioproc) audioproc->playSFX(sfx, 0x60, 1, 0);
return;
@ -393,8 +393,8 @@ void ActorAnimProcess::doSpecial() {
int32 x, y, z;
a->getLocation(x, y, z);
x += (std::rand() % (6 * 256)) - 3 * 256;
y += (std::rand() % (6 * 256)) - 3 * 256;
x += (getRandom() % (6 * 256)) - 3 * 256;
y += (getRandom() % (6 * 256)) - 3 * 256;
Actor *ghoul = Actor::createActor(0x8e, 0);
if (!ghoul) return;
@ -476,7 +476,7 @@ void ActorAnimProcess::doSpecial() {
if (sfx) {
AudioProcess *audioproc = AudioProcess::get_instance();
if (audioproc) audioproc->playSFX(sfx, 0x60, item_num, 0, false, 0x10000 + (std::rand() & 0x1FFF) - 0x1000);
if (audioproc) audioproc->playSFX(sfx, 0x60, item_num, 0, false, 0x10000 + (getRandom() & 0x1FFF) - 0x1000);
}
if (splash) {
@ -512,7 +512,7 @@ void ActorAnimProcess::doHitSpecial(Item *hit) {
switch (weaponshape) {
case 0x32F: // magic hammer
if (audioproc) audioproc->playSFX(23, 0x60, 1, 0, false,
0x10000 + (std::rand() & 0x1FFF) - 0x1000);
0x10000 + (getRandom() & 0x1FFF) - 0x1000);
break;
case 0x330: { // Slayer
// if we killed somebody, thunder&lightning
@ -520,7 +520,7 @@ void ActorAnimProcess::doHitSpecial(Item *hit) {
// calling intrinsic...
PaletteFaderProcess::I_lightningBolt(0, 0);
int sfx;
switch (std::rand() % 3) {
switch (getRandom() % 3) {
case 0:
sfx = 91;
break;
@ -537,9 +537,9 @@ void ActorAnimProcess::doHitSpecial(Item *hit) {
}
case 0x331: { // Flame Sting
int sfx = 33;
if (std::rand() % 2 == 0) sfx = 101;
if (getRandom() % 2 == 0) sfx = 101;
if (audioproc) audioproc->playSFX(sfx, 0x60, 1, 0, false,
0x10000 + (std::rand() & 0x1FFF) - 0x1000);
0x10000 + (getRandom() & 0x1FFF) - 0x1000);
int32 x, y, z;
a->getLocation(x, y, z);
@ -568,7 +568,7 @@ void ActorAnimProcess::doHitSpecial(Item *hit) {
0, 0, 0, fx, fy, fz);
ProcId cipid = kernel->addProcess(cip);
DelayProcess *dp2 = new DelayProcess(60 + (std::rand() % 60)); //2-4s
DelayProcess *dp2 = new DelayProcess(60 + (getRandom() % 60)); //2-4s
ProcId dp2id = kernel->addProcess(dp2);
DestroyItemProcess *dip = new DestroyItemProcess(0);

View File

@ -28,7 +28,6 @@
#include "ultima/ultima8/world/actors/animation.h"
#include "ultima/ultima8/kernel/kernel.h"
#include "ultima/ultima8/world/get_object.h"
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/filesys/odata_source.h"
@ -71,7 +70,7 @@ void ActorBarkNotifyProcess::run() {
// wait a short while (1-2.5 seconds) before doing the next animation
// (or even if not doing the animation)
Process *delayproc = new DelayProcess(30 + (std::rand() % 45));
Process *delayproc = new DelayProcess(30 + (getRandom() % 45));
ProcId delaypid = Kernel::get_instance()->addProcess(delayproc);
if (doAnim)

View File

@ -23,7 +23,7 @@
#ifndef WORLD_ACTORS_ANIMACTION_H
#define WORLD_ACTORS_ANIMACTION_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -232,8 +232,8 @@ void AvatarMoverProcess::handleCombatMode() {
lastAttack = lastframe;
// attacking gives str/dex
avatar->accumulateStr(1 + (std::rand() % 2));
avatar->accumulateDex(2 + (std::rand() % 2));
avatar->accumulateStr(1 + (getRandom() % 2));
avatar->accumulateDex(2 + (getRandom() % 2));
}
return;
@ -263,8 +263,8 @@ void AvatarMoverProcess::handleCombatMode() {
lastAttack = lastframe;
// kicking gives str/dex
avatar->accumulateStr(1 + (std::rand() % 2));
avatar->accumulateDex(2 + (std::rand() % 2));
avatar->accumulateStr(1 + (getRandom() % 2));
avatar->accumulateDex(2 + (getRandom() % 2));
}
return;
@ -555,15 +555,15 @@ void AvatarMoverProcess::handleNormalMode() {
// currently shaking head?
if (lastanim == Animation::lookLeft || lastanim == Animation::lookRight) {
if ((std::rand() % 1500) + 30 < idleTime) {
if ((getRandom() % 1500) + 30 < idleTime) {
lastHeadShakeAnim = lastanim;
waitFor(avatar->doAnim(Animation::stand, direction));
idleTime = 0;
return;
}
} else {
if ((std::rand() % 3000) + 150 < idleTime) {
if (std::rand() % 5 == 0)
if ((getRandom() % 3000) + 150 < idleTime) {
if (getRandom() % 5 == 0)
nextanim = lastHeadShakeAnim;
else if (lastHeadShakeAnim == Animation::lookLeft)
nextanim = Animation::lookRight;

View File

@ -112,7 +112,7 @@ void CombatProcess::run() {
bool hasidle1 = a->hasAnim(Animation::idle1);
bool hasidle2 = a->hasAnim(Animation::idle2);
if ((hasidle1 || hasidle2) && (std::rand() % 5) == 0) {
if ((hasidle1 || hasidle2) && (getRandom() % 5) == 0) {
// every once in a while, act threatening instead of attacking
// TODO: maybe make frequency depend on monster type
Animation::Sequence idleanim;
@ -122,7 +122,7 @@ void CombatProcess::run() {
} else if (!hasidle2) {
idleanim = Animation::idle1;
} else {
if (std::rand() % 2)
if (getRandom() % 2)
idleanim = Animation::idle1;
else
idleanim = Animation::idle2;
@ -306,7 +306,7 @@ void CombatProcess::waitForTarget() {
MonsterInfo *mi = 0;
if (shapeinfo) mi = shapeinfo->monsterinfo;
if (mi && mi->shifter && a->getMapNum() != 43 && (std::rand() % 2) == 0) {
if (mi && mi->shifter && a->getMapNum() != 43 && (getRandom() % 2) == 0) {
// changelings (except the ones at the U8 endgame pentagram)
// shift into a tree if nobody is around

View File

@ -142,9 +142,9 @@ void GrantPeaceProcess::run() {
int dir = caster->getDirToItemCentre(*t);
t->hurl(((std::rand() % 5) + 5) * x_fact[dir],
((std::rand() % 5) + 5) * y_fact[dir],
((std::rand() % 5) + 5),
t->hurl(((getRandom() % 5) + 5) * x_fact[dir],
((getRandom() % 5) + 5) * y_fact[dir],
((getRandom() % 5) + 5),
4);
#endif
}
@ -157,7 +157,7 @@ void GrantPeaceProcess::run() {
if (!(target->getActorFlags() & (Actor::ACT_DEAD |
Actor::ACT_IMMORTAL |
Actor::ACT_INVINCIBLE))) {
if (std::rand() % 10 == 0) {
if (getRandom() % 10 == 0) {
target->receiveHit(item_num, 8, target->getHP(),
(WeaponInfo::DMG_MAGIC |
WeaponInfo::DMG_PIERCE |
@ -175,7 +175,7 @@ void GrantPeaceProcess::run() {
// calling intrinsic...
PaletteFaderProcess::I_lightningBolt(0, 0);
int sfx;
switch (std::rand() % 3) {
switch (getRandom() % 3) {
case 0:
sfx = 91;
break;

View File

@ -67,8 +67,8 @@ void LoiterProcess::run() {
int32 x, y, z;
a->getLocation(x, y, z);
x += 32 * ((std::rand() % 20) - 10);
y += 32 * ((std::rand() % 20) - 10);
x += 32 * ((getRandom() % 20) - 10);
y += 32 * ((getRandom() % 20) - 10);
PathfinderProcess *pfp = new PathfinderProcess(a, x, y, z);
Kernel::get_instance()->addProcess(pfp);
@ -76,7 +76,7 @@ void LoiterProcess::run() {
bool hasidle1 = a->hasAnim(Animation::idle1);
bool hasidle2 = a->hasAnim(Animation::idle2);
if ((hasidle1 || hasidle2) && ((std::rand() % 3) == 0)) {
if ((hasidle1 || hasidle2) && ((getRandom() % 3) == 0)) {
Animation::Sequence idleanim;
if (!hasidle1) {
@ -84,7 +84,7 @@ void LoiterProcess::run() {
} else if (!hasidle2) {
idleanim = Animation::idle1;
} else {
if (std::rand() % 2)
if (getRandom() % 2)
idleanim = Animation::idle1;
else
idleanim = Animation::idle2;
@ -97,7 +97,7 @@ void LoiterProcess::run() {
} else {
// wait 4-7 sec
DelayProcess *dp = new DelayProcess(30 * (4 + (std::rand() % 3)));
DelayProcess *dp = new DelayProcess(30 * (4 + (getRandom() % 3)));
Kernel::get_instance()->addProcess(dp);
dp->waitFor(pfp);

View File

@ -260,7 +260,7 @@ int MainActor::getDamageAmount() {
kick_bonus = si->armourinfo[legs->getFrame()].kick_attack_bonus;
}
damage = (std::rand() % (getStr() / 2 + 1)) + kick_bonus;
damage = (getRandom() % (getStr() / 2 + 1)) + kick_bonus;
return damage;
@ -278,14 +278,14 @@ int MainActor::getDamageAmount() {
int base = si->weaponinfo->base_damage;
int mod = si->weaponinfo->damage_modifier;
damage = (std::rand() % (mod + 1)) + base + getStr() / 5;
damage = (getRandom() % (mod + 1)) + base + getStr() / 5;
return damage;
}
// no weapon?
damage = (std::rand() % (getStr() / 2 + 1)) + 1;
damage = (getRandom() % (getStr() / 2 + 1)) + 1;
return damage;
}
@ -466,7 +466,7 @@ void MainActor::accumulateStr(int n) {
if (strength == 25) return; //!! constant
accumStr += n;
if (accumStr >= 650 || std::rand() % (650 - accumStr) == 0) { //!! constant
if (accumStr >= 650 || getRandom() % (650 - accumStr) == 0) { //!! constant
strength++;
accumStr = 0;
AudioProcess *audioproc = AudioProcess::get_instance();
@ -480,7 +480,7 @@ void MainActor::accumulateDex(int n) {
if (dexterity == 25) return; //!! constant
accumDex += n;
if (accumDex >= 650 || std::rand() % (650 - accumDex) == 0) { //!! constant
if (accumDex >= 650 || getRandom() % (650 - accumDex) == 0) { //!! constant
dexterity++;
accumDex = 0;
AudioProcess *audioproc = AudioProcess::get_instance();
@ -494,7 +494,7 @@ void MainActor::accumulateInt(int n) {
if (intelligence == 25) return; //!! constant
accumInt += n;
if (accumInt >= 650 || std::rand() % (650 - accumInt) == 0) { //!! constant
if (accumInt >= 650 || getRandom() % (650 - accumInt) == 0) { //!! constant
intelligence++;
accumInt = 0;
AudioProcess *audioproc = AudioProcess::get_instance();

View File

@ -23,8 +23,8 @@
#ifndef ULTIMA8_WORLD_ACTORS_PATHFINDER_H
#define ULTIMA8_WORLD_ACTORS_PATHFINDER_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/world/actors/animation.h"
namespace Ultima {

View File

@ -23,8 +23,8 @@
#ifndef WORLD_ACTORS_TREASUREINFO_H
#define WORLD_ACTORS_TREASUREINFO_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/ultima8/std/string.h"
#include "ultima/shared/std/containers.h"
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef WORLD_ACTORS_WEAPONOVERLAY_H
#define WORLD_ACTORS_WEAPONOVERLAY_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -147,8 +147,8 @@ void CameraProcess::terminate() {
void CameraProcess::run() {
if (earthquake) {
eq_x = (std::rand() % (earthquake * 2 + 1)) - earthquake;
eq_y = (std::rand() % (earthquake * 2 + 1)) - earthquake;
eq_x = (getRandom() % (earthquake * 2 + 1)) - earthquake;
eq_y = (getRandom() % (earthquake * 2 + 1)) - earthquake;
} else {
eq_x = 0;
eq_y = 0;

View File

@ -24,7 +24,7 @@
#define ULTIMA8_WORLD_CONTAINER_H
#include "ultima/ultima8/world/item.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/usecode/intrinsics.h"
#include "ultima/ultima8/misc/p_dynamic_cast.h"

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_WORLD_CURRENTMAP_H
#define ULTIMA8_WORLD_CURRENTMAP_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/usecode/intrinsics.h"
namespace Ultima {

View File

@ -24,7 +24,7 @@
#define ULTIMA8_WORLD_EGGHATCHERPROCESS_H
#include "ultima/ultima8/kernel/process.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -33,7 +33,7 @@
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/filesys/odata_source.h"
#include "ultima/ultima8/std/misc.h"
#include "ultima/shared/std/misc.h"
namespace Ultima {
namespace Ultima8 {
@ -77,7 +77,7 @@ void FireballProcess::run() {
return;
}
if (age > 300 && (std::rand() % 20 == 0)) {
if (age > 300 && (getRandom() % 20 == 0)) {
// chance of 5% to disappear every frame after 10 seconds
terminate();
return;
@ -143,7 +143,7 @@ void FireballProcess::run() {
Actor *hit = getActor(hititem);
if (hit) {
// hit an actor: deal damage and explode
hit->receiveHit(0, 8 - targetdir, 5 + (std::rand() % 5),
hit->receiveHit(0, 8 - targetdir, 5 + (getRandom() % 5),
WeaponInfo::DMG_FIRE);
terminate();
return;

View File

@ -193,7 +193,7 @@ void GravityProcess::run() {
// Apply an impulse on the x/y plane in a random direction
// in a 180 degree pie around the orginal vector in x/y
double heading_r = atan2((double)yspeed, (double)xspeed);
double deltah_r = static_cast<double>(rand())
double deltah_r = static_cast<double>(getRandom())
* M_PI / RAND_MAX - M_PI / 2;
#ifdef BOUNCE_DIAG
double headingold_r = heading_r;

View File

@ -1240,12 +1240,12 @@ void Item::animateItem() {
switch (info->animtype) {
case 2:
// 50 % chance
if (std::rand() & 1) break;
if (getRandom() & 1) break;
case 1:
case 3:
// 50 % chance
if (anim_data == 1 && (std::rand() & 1)) break;
if (anim_data == 1 && (getRandom() & 1)) break;
frame ++;
if (anim_data < 2) {
if (shp && frame == shp->frameCount()) frame = 0;
@ -1257,7 +1257,7 @@ void Item::animateItem() {
break;
case 4:
if (!(std::rand() % anim_data)) break;
if (!(getRandom() % anim_data)) break;
frame ++;
if (shp && frame == shp->frameCount()) frame = 0;
//dirty = true;
@ -1513,7 +1513,7 @@ void Item::explode() {
x, y, z);
Kernel::get_instance()->addProcess(p);
int sfx = (std::rand() % 2) ? 31 : 158;
int sfx = (getRandom() % 2) ? 31 : 158;
AudioProcess *audioproc = AudioProcess::get_instance();
if (audioproc) audioproc->playSFX(sfx, 0x60, 0, 0);
@ -1536,7 +1536,7 @@ void Item::explode() {
item->getLocation(xv, yv, zv);
int dir = Get_WorldDirection(xv - xv, yv - yv); //!! CHECKME
item->receiveHit(0, dir, 6 + (std::rand() % 6),
item->receiveHit(0, dir, 6 + (getRandom() % 6),
WeaponInfo::DMG_BLUNT | WeaponInfo::DMG_FIRE);
}
}

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_WORLD_MAP_H
#define ULTIMA8_WORLD_MAP_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -23,7 +23,7 @@
#ifndef ULTIMA8_WORLD_MAPGLOB_H
#define ULTIMA8_WORLD_MAPGLOB_H
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -57,7 +57,7 @@
// game data need this, actually.)
#include "ultima/ultima8/misc/common_types.h"
#include "ultima/ultima8/std/containers.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
namespace Ultima8 {