freg  0.3
Free-Roaming Elementary Game
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
World Class Referencefinal

World provides global physics and shred connection. More...

#include <World.h>

Inheritance diagram for World:
Inheritance graph
[legend]
Collaboration diagram for World:
Collaboration graph
[legend]

Public Slots

void SetReloadShreds (int direction)
 
void PhysEvents ()
 

Signals

void Notify (QString) const
 
void GetString (QString &) const
 
void Updated (int, int, int)
 
void UpdatedAll ()
 
void UpdatedAround (int x, int y, int z, int range)
 
void StartMove (int)
 
void Moved (int)
 Emitted when world active zone moved to int direction. More...
 
void UpdatesEnded ()
 This is emitted when a pack of updates is complete. More...
 
void NeedPlayer (int, int, int)
 
void StartReloadAll ()
 
void FinishReloadAll ()
 
void ExitReceived ()
 

Public Member Functions

 World (QString world_name, bool *error)
 
 ~World ()
 
BlockGetBlock (int x, int y, int z) const
 
ShredGetShred (int i, int j) const
 
ShredGetShredByPos (int x, int y) const
 
ShredGetNearShred (Shred *, dirs dir) const
 
int Enlightened (int x, int y, int z) const
 
int Enlightened (int x, int y, int z, dirs dir) const
 Provides lighting of block side, not all block. More...
 
int SunLight (int x, int y, int z) const
 
int FireLight (int x, int y, int z) const
 
int LightMap (int x, int y, int z) const
 Use Enlightened instead, which is smart wrapper of this. More...
 
int ClampX (int x) const
 
int ClampY (int y) const
 
int ClampZ (int z) const
 
void SunShineVertical (int x, int y, int z=HEIGHT-2, int level=MAX_LIGHT_RADIUS)
 
void SunShineHorizontal (int x, int y, int z)
 
void Shine (int x, int y, int z, int level)
 If init is false, light will not spread from non-invisible blocks. More...
 
void RemoveSunLight (int x, int y, int z)
 
bool GetEvernight () const
 
QString WorldName () const
 
bool Focus (int x, int y, int z, int *x_targ, int *y_targ, int *z_targ, dirs dir) const
 False on error, true if focus is received to _targ successfully. More...
 
int NumShreds () const
 
bool ShredInCentralZone (long longi, long lati) const
 
long Longitude () const
 
long Latitude () const
 
const WorldMapGetMap () const
 
QByteArray * GetShredData (long longi, long lati) const
 
void SetShredData (QByteArray *, long longi, long lati)
 
bool DirectlyVisible (int x_from, int y_from, int z_from, int x_to, int y_to, int z_to) const
 
bool Visible (int x_from, int y_from, int z_from, int x_to, int y_to, int z_to) const
 At least one side of block is visible. More...
 
bool Move (int x, int y, int z, dirs dir)
 Check and move. More...
 
void Jump (int x, int y, int z, dirs dir)
 
times_of_day PartOfDay () const
 
int TimeOfDay () const
 This returns seconds from start of current day. More...
 
ulong Time () const
 Returns time in seconds since world creation. More...
 
QString TimeOfDayStr () const
 
int MiniTime () const
 Returns number of physics steps since second start. More...
 
int Damage (int x, int y, int z, int level, int dmg_kind)
 Returns damaged block result durability. More...
 
void DestroyAndReplace (int x, int y, int z)
 Does not check target block durability. More...
 
bool Build (Block *thing, int x, int y, int z, int dir=UP, Block *who=nullptr, bool anyway=false)
 Returns true on successfull build, otherwise false. More...
 
bool Inscribe (int x, int y, int z)
 Returns true on success. Gets a string and inscribes block. More...
 
bool Drop (Block *from, int x_to, int y_to, int z_to, int src, int dest, int num)
 Returns true on success. More...
 
bool Get (Block *to, int x_from, int y_from, int z_from, int src, int dest, int num)
 
bool InBounds (int x, int y) const
 
bool InBounds (int x, int y, int z) const
 
int GetBound () const
 
int SetNote (QString note)
 
int ChangeNote (QString note, int note_id)
 
QString GetNote (int note_id) const
 
void ReloadAllShreds (long lati, long longi, int new_x, int new_y, int new_z)
 
QMutex * GetLock ()
 
void Lock ()
 
bool TryLock ()
 
void Unlock ()
 

Static Public Member Functions

static dirs TurnRight (dirs dir)
 
static dirs TurnLeft (dirs dir)
 
static dirs Anti (dirs dir)
 
static bool InVertBounds (int z)
 

Private Member Functions

bool SetFireLightMap (int level, int x, int y, int z)
 
void AddFireLight (int x, int y, int z, int level)
 
void RemoveFireLight (int x, int y, int z)
 
void ReEnlighten (int x, int y, int z)
 Called when block is moved. More...
 
void ReEnlightenAll ()
 
void ReEnlightenTime ()
 
void ReEnlightenMove (dirs)
 Called from ReloadShreds(int), enlightens only needed shreds. More...
 
void UpShine (int x, int y, int z_bottom)
 
void UpShineInit (int x, int y, int z_bottom)
 
void CrossUpShine (int x, int y, int z_bottom)
 
int ShredPos (int x, int y) const
 
can_move_results CanMove (int x, int y, int z, int x_to, int y_to, int z_to, dirs dir)
 This CAN move blocks, but not xyz block. More...
 
void NoCheckMove (int x, int y, int z, int x_to, int y_to, int z_to, dirs dir)
 
bool Exchange (Block *block_from, Block *block_to, int src, int dest, int num)
 Returns true if block_from can be put into block_to. More...
 
void SetNumActiveShreds (int num)
 
void DeleteAllShreds ()
 Also saves all shreds. More...
 
void LoadAllShreds ()
 
void ReloadShreds ()
 
void run () override
 
Shred ** FindShred (int x, int y) const
 
 World (const World &)=delete
 
Worldoperator= (const World &)=delete
 

Private Attributes

const QString worldName
 
const WorldMap map
 
QSettings settings
 
ulong time
 
int timeStep
 
Shred ** shreds
 
long longitude
 
long latitude
 
int numShreds
 size of loaded zone More...
 
int numActiveShreds
 size of active zone More...
 
QMutex mutex
 
const bool evernight
 
long newLati
 
long newLongi
 
int newX
 
int newY
 
int newZ
 
volatile dirs toResetDir
 UP for no reset, DOWN for full reset, NSEW for side shift. More...
 
int sunMoonFactor
 
ShredStorageshredStorage
 
bool initial_lighting
 
QList< QString > notes
 

Detailed Description

World provides global physics and shred connection.

Designed to be single.

Definition at line 52 of file World.h.

Constructor & Destructor Documentation

World::World ( QString  world_name,
bool *  error 
)

Definition at line 657 of file World.cpp.

World::~World ( )

Definition at line 720 of file World.cpp.

World::World ( const World )
privatedelete

Member Function Documentation

void World::AddFireLight ( int  x,
int  y,
int  z,
int  level 
)
private

Definition at line 55 of file Lighting-inertia.cpp.

dirs World::Anti ( dirs  dir)
static

Definition at line 191 of file World.cpp.

bool World::Build ( Block thing,
int  x,
int  y,
int  z,
int  dir = UP,
Block who = nullptr,
bool  anyway = false 
)

Returns true on successfull build, otherwise false.

Definition at line 550 of file World.cpp.

can_move_results World::CanMove ( int  x,
int  y,
int  z,
int  x_to,
int  y_to,
int  z_to,
dirs  dir 
)
private

This CAN move blocks, but not xyz block.

Definition at line 391 of file World.cpp.

int World::ChangeNote ( QString  note,
int  note_id 
)

Definition at line 138 of file World.cpp.

int World::ClampX ( int  x) const
int World::ClampY ( int  y) const
int World::ClampZ ( int  z) const
void World::CrossUpShine ( int  x,
int  y,
int  z_bottom 
)
private

Definition at line 106 of file Lighting-inertia.cpp.

int World::Damage ( int  x,
int  y,
int  z,
int  level,
int  dmg_kind 
)

Returns damaged block result durability.

Definition at line 508 of file World.cpp.

void World::DeleteAllShreds ( )
private

Also saves all shreds.

Definition at line 632 of file World.cpp.

void World::DestroyAndReplace ( int  x,
int  y,
int  z 
)

Does not check target block durability.

Definition at line 525 of file World.cpp.

bool World::DirectlyVisible ( int  x_from,
int  y_from,
int  z_from,
int  x_to,
int  y_to,
int  z_to 
) const

optimized DDA line with integers only.

Definition at line 326 of file World.cpp.

bool World::Drop ( Block from,
int  x_to,
int  y_to,
int  z_to,
int  src,
int  dest,
int  num 
)

Returns true on success.

Definition at line 88 of file World.cpp.

int World::Enlightened ( int  x,
int  y,
int  z 
) const

Definition at line 199 of file Lighting-inertia.cpp.

int World::Enlightened ( int  x,
int  y,
int  z,
dirs  dir 
) const

Provides lighting of block side, not all block.

Definition at line 206 of file Lighting-inertia.cpp.

bool World::Exchange ( Block block_from,
Block block_to,
int  src,
int  dest,
int  num 
)
private

Returns true if block_from can be put into block_to.

Definition at line 593 of file World.cpp.

void World::ExitReceived ( )
signal
Shred ** World::FindShred ( int  x,
int  y 
) const
private

Definition at line 209 of file World.cpp.

void World::FinishReloadAll ( )
signal
int World::FireLight ( int  x,
int  y,
int  z 
) const

Definition at line 217 of file Lighting-inertia.cpp.

bool World::Focus ( int  x,
int  y,
int  z,
int *  x_targ,
int *  y_targ,
int *  z_targ,
dirs  dir 
) const

False on error, true if focus is received to _targ successfully.

Definition at line 491 of file World.cpp.

bool World::Get ( Block to,
int  x_from,
int  y_from,
int  z_from,
int  src,
int  dest,
int  num 
)

Definition at line 99 of file World.cpp.

Block * World::GetBlock ( int  x,
int  y,
int  z 
) const

Definition at line 204 of file World.cpp.

int World::GetBound ( ) const

Definition at line 126 of file World.cpp.

bool World::GetEvernight ( ) const

Definition at line 64 of file World.cpp.

QMutex * World::GetLock ( )

Definition at line 160 of file World.cpp.

const WorldMap * World::GetMap ( ) const

Definition at line 66 of file World.cpp.

Shred * World::GetNearShred ( Shred shred,
dirs  dir 
) const

Definition at line 48 of file World.cpp.

QString World::GetNote ( int  note_id) const

Definition at line 147 of file World.cpp.

Shred * World::GetShred ( int  i,
int  j 
) const

Definition at line 40 of file World.cpp.

Shred * World::GetShredByPos ( int  x,
int  y 
) const

Definition at line 44 of file World.cpp.

QByteArray * World::GetShredData ( long  longi,
long  lati 
) const

Definition at line 68 of file World.cpp.

void World::GetString ( QString &  ) const
signal
bool World::InBounds ( int  x,
int  y 
) const

Definition at line 117 of file World.cpp.

bool World::InBounds ( int  x,
int  y,
int  z 
) const

Definition at line 122 of file World.cpp.

bool World::Inscribe ( int  x,
int  y,
int  z 
)

Returns true on success. Gets a string and inscribes block.

Definition at line 579 of file World.cpp.

bool World::InVertBounds ( int  z)
static

Definition at line 131 of file World.cpp.

void World::Jump ( int  x,
int  y,
int  z,
dirs  dir 
)

Definition at line 483 of file World.cpp.

long World::Latitude ( ) const

Definition at line 63 of file World.cpp.

int World::LightMap ( int  x,
int  y,
int  z 
) const

Use Enlightened instead, which is smart wrapper of this.

Definition at line 43 of file Lighting-inertia.cpp.

void World::LoadAllShreds ( )
private

Definition at line 621 of file World.cpp.

void World::Lock ( )

Definition at line 161 of file World.cpp.

long World::Longitude ( ) const

Definition at line 62 of file World.cpp.

int World::MiniTime ( ) const

Returns number of physics steps since second start.

Definition at line 60 of file World.cpp.

bool World::Move ( int  x,
int  y,
int  z,
dirs  dir 
)

Check and move.

Definition at line 375 of file World.cpp.

void World::Moved ( int  )
signal

Emitted when world active zone moved to int direction.

void World::NeedPlayer ( int  ,
int  ,
int   
)
signal
void World::NoCheckMove ( int  x,
int  y,
int  z,
int  x_to,
int  y_to,
int  z_to,
dirs  dir 
)
private

Definition at line 449 of file World.cpp.

void World::Notify ( QString  ) const
signal
int World::NumShreds ( ) const

Definition at line 58 of file World.cpp.

World& World::operator= ( const World )
privatedelete
times_of_day World::PartOfDay ( ) const

Definition at line 78 of file World.cpp.

void World::PhysEvents ( )
slot

Definition at line 298 of file World.cpp.

void World::ReEnlighten ( int  x,
int  y,
int  z 
)
private

Called when block is moved.

Called when one block is moved, built or destroyed.

Definition at line 140 of file Lighting-inertia.cpp.

void World::ReEnlightenAll ( )
private

Definition at line 159 of file Lighting-inertia.cpp.

void World::ReEnlightenMove ( dirs  dir)
private

Called from ReloadShreds(int), enlightens only needed shreds.

Definition at line 167 of file Lighting-inertia.cpp.

void World::ReEnlightenTime ( )
private

Definition at line 150 of file Lighting-inertia.cpp.

void World::ReloadAllShreds ( long  lati,
long  longi,
int  new_x,
int  new_y,
int  new_z 
)

Definition at line 149 of file World.cpp.

void World::ReloadShreds ( )
private

Definition at line 213 of file World.cpp.

void World::RemoveFireLight ( int  x,
int  y,
int  z 
)
private

Definition at line 56 of file Lighting-inertia.cpp.

void World::RemoveSunLight ( int  x,
int  y,
int  z 
)
void World::run ( )
overrideprivate

Definition at line 291 of file World.cpp.

bool World::SetFireLightMap ( int  level,
int  x,
int  y,
int  z 
)
private

Definition at line 48 of file Lighting-inertia.cpp.

int World::SetNote ( QString  note)

Definition at line 133 of file World.cpp.

void World::SetNumActiveShreds ( int  num)
private

Definition at line 638 of file World.cpp.

void World::SetReloadShreds ( int  direction)
slot

Definition at line 287 of file World.cpp.

void World::SetShredData ( QByteArray *  data,
long  longi,
long  lati 
)

Definition at line 72 of file World.cpp.

void World::Shine ( int  x,
int  y,
int  z,
int  level 
)

If init is false, light will not spread from non-invisible blocks.

Makes block emit shining.

Receives only non-sun light as level, from 1 to F.

Definition at line 60 of file Lighting-inertia.cpp.

bool World::ShredInCentralZone ( long  longi,
long  lati 
) const

Definition at line 34 of file World.cpp.

int World::ShredPos ( int  x,
int  y 
) const
private

Definition at line 38 of file World.cpp.

void World::StartMove ( int  )
signal
void World::StartReloadAll ( )
signal
int World::SunLight ( int  x,
int  y,
int  z 
) const

Definition at line 213 of file Lighting-inertia.cpp.

void World::SunShineHorizontal ( int  x,
int  y,
int  z 
)
void World::SunShineVertical ( int  x,
int  y,
int  z = HEIGHT-2,
int  level = MAX_LIGHT_RADIUS 
)

Definition at line 79 of file Lighting-inertia.cpp.

ulong World::Time ( ) const

Returns time in seconds since world creation.

Definition at line 61 of file World.cpp.

int World::TimeOfDay ( ) const

This returns seconds from start of current day.

Definition at line 59 of file World.cpp.

QString World::TimeOfDayStr ( ) const

Definition at line 82 of file World.cpp.

bool World::TryLock ( )

Definition at line 162 of file World.cpp.

dirs World::TurnLeft ( dirs  dir)
static

Definition at line 178 of file World.cpp.

dirs World::TurnRight ( dirs  dir)
static

Definition at line 165 of file World.cpp.

void World::Unlock ( )

Definition at line 163 of file World.cpp.

void World::Updated ( int  ,
int  ,
int   
)
signal
void World::UpdatedAll ( )
signal
void World::UpdatedAround ( int  x,
int  y,
int  z,
int  range 
)
signal
void World::UpdatesEnded ( )
signal

This is emitted when a pack of updates is complete.

void World::UpShine ( int  x,
int  y,
int  z_bottom 
)
private

Definition at line 130 of file Lighting-inertia.cpp.

void World::UpShineInit ( int  x,
int  y,
int  z_bottom 
)
private

Definition at line 122 of file Lighting-inertia.cpp.

bool World::Visible ( int  x_from,
int  y_from,
int  z_from,
int  x_to,
int  y_to,
int  z_to 
) const

At least one side of block is visible.

Definition at line 354 of file World.cpp.

QString World::WorldName ( ) const

Definition at line 65 of file World.cpp.

Member Data Documentation

const bool World::evernight
private

Definition at line 242 of file World.h.

bool World::initial_lighting
private

Definition at line 250 of file World.h.

long World::latitude
private

Definition at line 238 of file World.h.

long World::longitude
private

N | E W–+–> latitude ( x for shreds ) | S v longitude ( y for shreds ) center of active zone:

Definition at line 238 of file World.h.

const WorldMap World::map
private

Definition at line 227 of file World.h.

QMutex World::mutex
private

Definition at line 241 of file World.h.

long World::newLati
private

Definition at line 243 of file World.h.

long World::newLongi
private

Definition at line 243 of file World.h.

int World::newX
private

Definition at line 244 of file World.h.

int World::newY
private

Definition at line 244 of file World.h.

int World::newZ
private

Definition at line 244 of file World.h.

QList<QString> World::notes
private

Definition at line 251 of file World.h.

int World::numActiveShreds
private

size of active zone

Definition at line 240 of file World.h.

int World::numShreds
private

size of loaded zone

Definition at line 239 of file World.h.

QSettings World::settings
private

Definition at line 228 of file World.h.

Shred** World::shreds
private

Definition at line 231 of file World.h.

ShredStorage* World::shredStorage
private

Definition at line 249 of file World.h.

int World::sunMoonFactor
private

Definition at line 247 of file World.h.

ulong World::time
private

Definition at line 229 of file World.h.

int World::timeStep
private

Definition at line 230 of file World.h.

volatile dirs World::toResetDir
private

UP for no reset, DOWN for full reset, NSEW for side shift.

Definition at line 246 of file World.h.

const QString World::worldName
private

Definition at line 226 of file World.h.


The documentation for this class was generated from the following files: