$treeview $search $mathjax
Stratagus  2.2.7
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

src/stratagus/util.cpp File Reference

#include "stratagus.h"
#include "util.h"
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

util.cpp - General utilites.

unsigned SyncRandSeed
void InitSyncRand ()
 sync random seed value.
int SyncRand ()
 Initialize the syncron rand.
int SyncRand (int max)
 Syncron rand.
int MyRand ()
 Syncron rand.
long isqrt (long num)
 Compute a square root using ints.
unsigned int strcpy_s (char *dst, size_t dstsize, const char *src)
size_t strnlen (const char *str, size_t strsize)
 determine length of a fixed-length string
unsigned int strncpy_s (char *dst, size_t dstsize, const char *src, size_t count)
unsigned int strcat_s (char *dst, size_t dstsize, const char *src)
char * strcasestr (const char *a, const char *b)
 case insensitive strstr
int GetClipboard (std::string &str)
int UTF8GetPrev (const std::string &text, int curpos)
int UTF8GetNext (const std::string &text, int curpos)

Function Documentation

int GetClipboard ( std::string &  str  ) 

Standard implementation of getopt(3).

One extension: If the first character of the optionsstring is a ':' the error return for 'argument required' is a ':' not a '?'. This makes it easier to differentiate between an 'illegal option' and an 'argument required' error. Paste text from the clipboard

void InitSyncRand (  ) 

sync random seed value.

Sync random seed value.

Inititalize sync rand seed.

long isqrt ( long  num  ) 

Compute a square root using ints.

Compute a square root using ints

Uses John Halleck's method, see http://www.cc.utah.edu/~nahaj/factoring/isqrt.legalize.c.html

Parameters:
num Calculate the square root of this number
Returns:
The integer square root.

int MyRand (  ) 

Syncron rand.

rand only used on this computer.

char* strcasestr ( const char *  a,
const char *  b 
)

case insensitive strstr

Case insensitive version of strstr

Parameters:
a String to search in
b Substring to search for
Returns:
Pointer to first occurence of b or NULL if not found.

unsigned int strcat_s ( char *  dst,
size_t  dstsize,
const char *  src 
)

unsigned int strcpy_s ( char *  dst,
size_t  dstsize,
const char *  src 
)

unsigned int strncpy_s ( char *  dst,
size_t  dstsize,
const char *  src,
size_t  count 
)

size_t strnlen ( const char *  str,
size_t  strsize 
)

determine length of a fixed-length string

int SyncRand ( int  max  ) 

Syncron rand.

Synchronized random number.

Parameters:
max Max value of random number to return

int SyncRand (  ) 

Initialize the syncron rand.

Synchronized random number.

Note:
This random value must be same on all machines in network game. Very simple random generations, enough for us.

int UTF8GetNext ( const std::string &  text,
int  curpos 
)

int UTF8GetPrev ( const std::string &  text,
int  curpos 
)


Variable Documentation

unsigned SyncRandSeed

(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.