Merge branch 'master' into console-func-refactor

Conflicts:
	Engine/source/app/net/net.cpp
	Engine/source/console/astNodes.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/console/console.h
	Engine/source/console/consoleInternal.h
	Engine/source/console/engineAPI.h
This commit is contained in:
Daniel Buckmaster 2014-10-14 14:40:17 +11:00
commit b507dc9555
6487 changed files with 315149 additions and 609761 deletions

View file

@ -27,7 +27,7 @@
#include "platform/platform.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#include "platform/input/event.h"
#endif
#include <stdio.h>

View file

@ -22,25 +22,30 @@
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/threads/semaphore.h"
// Instead of that mess that was here before, lets use the SDL lib to deal
// with the semaphores.
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <semaphore.h>
#include <time.h>
struct PlatformSemaphore
{
SDL_sem *semaphore;
sem_t semaphore;
bool initialized;
PlatformSemaphore(S32 initialCount)
{
semaphore = SDL_CreateSemaphore(initialCount);
AssertFatal(semaphore, "PlatformSemaphore constructor - Failed to create SDL Semaphore.");
initialized = true;
if (sem_init(&semaphore, 0, initialCount) == -1) {
initialized = false;
AssertFatal(0, "PlatformSemaphore constructor - Failed to create Semaphore.");
}
}
~PlatformSemaphore()
{
SDL_DestroySemaphore(semaphore);
sem_destroy(&semaphore);
initialized = false;
}
};
@ -57,28 +62,37 @@ Semaphore::~Semaphore()
bool Semaphore::acquire(bool block, S32 timeoutMS)
{
AssertFatal(mData && mData->semaphore, "Semaphore::acquire - Invalid semaphore.");
AssertFatal(mData && mData->initialized, "Semaphore::acquire - Invalid semaphore.");
if (block)
{
//SDL was removed so I do not now if this still holds true or not with OS calls but my guess is they are used underneath SDL anyway
// Semaphore acquiring is different from the MacOS/Win realization because SDL_SemWaitTimeout() with "infinite" timeout can be too heavy on some platforms.
// (see "man SDL_SemWaitTimeout(3)" for more info)
// "man" states to avoid the use of SDL_SemWaitTimeout at all, but at current stage this looks like a valid and working solution, so keeping it this way.
// [bank / Feb-2010]
if (timeoutMS == -1)
{
if (SDL_SemWait(mData->semaphore) < 0)
AssertFatal(false, "Semaphore::acquie - Wait failed.");
if (sem_wait(&mData->semaphore) < 0)
AssertFatal(false, "Semaphore::acquire - Wait failed.");
}
else
{
if (SDL_SemWaitTimeout(mData->semaphore, timeoutMS) < 0)
AssertFatal(false, "Semaphore::acquie - Wait with timeout failed.");
//convert timeoutMS to timespec
timespec ts;
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
AssertFatal(false, "Semaphore::acquire - clock_realtime failed.");
}
ts.tv_sec += timeoutMS / 1000;
ts.tv_nsec += (timeoutMS % 1000) * 1000;
if (sem_timedwait(&mData->semaphore, &ts) < 0)
AssertFatal(false, "Semaphore::acquire - Wait with timeout failed.");
}
return (true);
}
else
{
int res = SDL_SemTryWait(mData->semaphore);
int res = sem_trywait(&mData->semaphore);
return (res == 0);
}
}
@ -86,5 +100,5 @@ bool Semaphore::acquire(bool block, S32 timeoutMS)
void Semaphore::release()
{
AssertFatal(mData, "Semaphore::releaseSemaphore - Invalid semaphore.");
SDL_SemPost(mData->semaphore);
sem_post(&mData->semaphore);
}

View file

@ -23,7 +23,7 @@
#include "platformX86UNIX/platformX86UNIX.h"
#include "platformX86UNIX/x86UNIXStdConsole.h"
#include "platformX86UNIX/x86UNIXUtils.h"
#include "platform/event.h"
#include "platform/input/event.h"
#include "platform/platform.h"
#include "core/util/rawData.h"
#include "core/strings/stringFunctions.h"
@ -217,7 +217,7 @@ void StdConsole::process()
// mojo for select call
fd_set rfds;
struct timeval tv;
int retval;
FD_ZERO(&rfds);
FD_SET(stdIn, &rfds);
// don't wait at all in select

View file

@ -56,6 +56,7 @@
#include "core/strings/stringFunctions.h"
#include "util/tempAlloc.h"
#include "cinterface/cinterface.h"
#include "core/volume.h"
#if defined(__FreeBSD__)
#include <sys/types.h>
@ -468,7 +469,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
// Sets capability appropriate to the openMode.
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::open(const char *filename, const AccessMode openMode)
File::FileStatus File::open(const char *filename, const AccessMode openMode)
{
AssertFatal(NULL != filename, "File::open: NULL filename");
AssertWarn(NULL == handle, "File::open: handle already valid");
@ -583,7 +584,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
//
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::setPosition(S32 position, bool absolutePos)
File::FileStatus File::setPosition(S32 position, bool absolutePos)
{
AssertFatal(Closed != currentStatus, "File::setPosition: file closed");
AssertFatal(NULL != handle, "File::setPosition: invalid file handle");
@ -644,7 +645,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
// It is an error to flush a read-only file.
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::flush()
File::FileStatus File::flush()
{
AssertFatal(Closed != currentStatus, "File::flush: file closed");
AssertFatal(NULL != handle, "File::flush: invalid file handle");
@ -661,7 +662,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
//
// Returns the currentStatus
//-----------------------------------------------------------------------------
File::Status File::close()
File::FileStatus File::close()
{
// if the handle is non-NULL, close it if necessary and free it
if (NULL != handle)
@ -683,7 +684,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
//-----------------------------------------------------------------------------
// Self-explanatory.
//-----------------------------------------------------------------------------
File::Status File::getStatus() const
File::FileStatus File::getStatus() const
{
return currentStatus;
}
@ -691,7 +692,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
//-----------------------------------------------------------------------------
// Sets and returns the currentStatus when an error has been encountered.
//-----------------------------------------------------------------------------
File::Status File::setStatus()
File::FileStatus File::setStatus()
{
Con::printf("File IO error: %s", strerror(errno));
return currentStatus = IOError;
@ -700,7 +701,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
//-----------------------------------------------------------------------------
// Sets and returns the currentStatus to status.
//-----------------------------------------------------------------------------
File::Status File::setStatus(File::Status status)
File::FileStatus File::setStatus(File::FileStatus status)
{
return currentStatus = status;
}
@ -711,7 +712,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
// The number of bytes read is available in bytesRead if a non-Null pointer is
// provided.
//-----------------------------------------------------------------------------
File::Status File::read(U32 size, char *dst, U32 *bytesRead)
File::FileStatus File::read(U32 size, char *dst, U32 *bytesRead)
{
#ifdef DEBUG
// fprintf(stdout,"reading %d bytes\n",size);fflush(stdout);
@ -769,7 +770,7 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
// The number of bytes written is available in bytesWritten if a non-Null
// pointer is provided.
//-----------------------------------------------------------------------------
File::Status File::write(U32 size, const char *src, U32 *bytesWritten)
File::FileStatus File::write(U32 size, const char *src, U32 *bytesWritten)
{
// JMQ: despite the U32 parameters, the maximum filesize supported by this
// function is probably the max value of S32, due to the unix syscall
@ -980,7 +981,10 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
// Get file info
struct stat fStat;
if (stat(pFilePath, &fStat) < 0)
return false;
{
// Since file does not exist on disk see if it exists in a zip file loaded
return Torque::FS::IsFile(pFilePath);
}
// if the file is a "regular file" then true
if ( (fStat.st_mode & S_IFMT) == S_IFREG)

View file

@ -49,7 +49,7 @@ void Platform::init()
//installRedBookDevices();
#if 0
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
// if we're not dedicated do more initialization
if (!x86UNIXState->isDedicated())
{

View file

@ -30,7 +30,7 @@
#include <unistd.h>
#include <signal.h>
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
#include <SDL/SDL.h>
#endif
@ -80,7 +80,10 @@ void Cleanup(bool minimal)
}
StdConsole::destroy();
#ifndef TORQUE_DEDICATED
SDL_Quit();
#endif
}
//-----------------------------------------------------------------------------

View file

@ -20,6 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// Not needed on dedicated (SDL is not not linked against when dedicated)
#ifndef TORQUE_DEDICATED
#include "console/console.h"
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/platformRedBook.h"
@ -453,3 +455,4 @@ void PollRedbookDevices()
}
#endif // !defined(__FreeBSD__)
}
#endif

View file

@ -25,7 +25,7 @@
//#include "platformX86UNIX/platformGL.h"
#include "core/strings/stringFunctions.h"
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
#include <X11/Xlib.h> // for Display, Window and other X mojo
#else
#define Display int
@ -225,7 +225,7 @@ class DisplayPtrManager
private:
Display* openDisplay()
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
mDisplay = XOpenDisplay(NULL);
if (mDisplay != NULL)
mOpenedDisplay = true;
@ -237,7 +237,7 @@ class DisplayPtrManager
{
if (mOpenedDisplay)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
XCloseDisplay(mDisplay);
mDisplay = NULL;
mOpenedDisplay = false;

View file

@ -92,7 +92,8 @@ void Platform::openFolder(const char *path) { }
void Platform::openFile(const char *path) { }
// window
bool Platform::displaySplashWindow() { return false; }
bool Platform::displaySplashWindow(String path) { return false; }
bool Platform::closeSplashWindow() { return false; }
// font
PlatformFont *createPlatformFont(const char *name, U32 size, U32 charset) { return NULL; }

View file

@ -40,7 +40,7 @@
#include "platformX86UNIX/x86UNIXOGLVideo.h"
#include "platformX86UNIX/x86UNIXState.h"
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
#include "platformX86UNIX/x86UNIXMessageBox.h"
#include "platformX86UNIX/x86UNIXInputManager.h"
#endif
@ -51,7 +51,7 @@
#include <unistd.h> // fork, execvp, chdir
#include <time.h> // nanosleep
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
#include <X11/Xlib.h>
#include <X11/Xos.h>
@ -69,7 +69,7 @@ LockFunc_t DisplayPtrManager::sgUnlockFunc = NULL;
static U32 lastTimeTick;
static MRandomLCG sgPlatRandom;
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
extern void InstallRedBookDevices();
extern void PollRedbookDevices();
extern bool InitOpenGL();
@ -149,7 +149,7 @@ static S32 ParseCommandLine(S32 argc, const char **argv,
static void DetectWindowingSystem()
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
Display* dpy = XOpenDisplay(NULL);
if (dpy != NULL)
{
@ -166,7 +166,7 @@ static void InitWindow(const Point2I &initialSize, const char *name)
x86UNIXState->setWindowName(name);
}
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
//------------------------------------------------------------------------------
static bool InitSDL()
{
@ -376,7 +376,7 @@ static inline void Sleep(int secs, int nanoSecs)
nanosleep(&sleeptime, NULL);
}
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
struct AlertWinState
{
bool fullScreen;
@ -436,7 +436,7 @@ static inline void AlertEnableVideo(AlertWinState& state)
//------------------------------------------------------------------------------
void Platform::AlertOK(const char *windowTitle, const char *message)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
if (x86UNIXState->isXWindowsRunning())
{
AlertWinState state;
@ -461,7 +461,7 @@ void Platform::AlertOK(const char *windowTitle, const char *message)
//------------------------------------------------------------------------------
bool Platform::AlertOKCancel(const char *windowTitle, const char *message)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
if (x86UNIXState->isXWindowsRunning())
{
AlertWinState state;
@ -489,7 +489,7 @@ bool Platform::AlertOKCancel(const char *windowTitle, const char *message)
//------------------------------------------------------------------------------
bool Platform::AlertRetry(const char *windowTitle, const char *message)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
if (x86UNIXState->isXWindowsRunning())
{
AlertWinState state;
@ -524,7 +524,7 @@ bool Platform::excludeOtherInstances(const char *mutexName)
//------------------------------------------------------------------------------
void Platform::enableKeyboardTranslation(void)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
// JMQ: not sure if this is needed for i18n keyboards
//SDL_EnableUNICODE( 1 );
// SDL_EnableKeyRepeat(
@ -536,7 +536,7 @@ void Platform::enableKeyboardTranslation(void)
//------------------------------------------------------------------------------
void Platform::disableKeyboardTranslation(void)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
//SDL_EnableUNICODE( 0 );
// SDL_EnableKeyRepeat(0, 0);
#endif
@ -545,7 +545,7 @@ void Platform::disableKeyboardTranslation(void)
//------------------------------------------------------------------------------
void Platform::setWindowLocked(bool locked)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
x86UNIXState->setWindowLocked(locked);
UInputManager* uInputManager =
@ -560,7 +560,7 @@ void Platform::setWindowLocked(bool locked)
//------------------------------------------------------------------------------
void Platform::minimizeWindow()
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
if (x86UNIXState->windowCreated())
SDL_WM_IconifyWindow();
#endif
@ -574,7 +574,7 @@ void Platform::process()
if (x86UNIXState->windowCreated())
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
// process window events
PROFILE_START(XUX_ProcessMessages);
bool quit = !ProcessMessages();
@ -622,7 +622,7 @@ void Platform::process()
}
}
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
#if 0
// JMQ: disabled this because it may fire mistakenly in some configurations.
// sdl's default event handling scheme should be enough.
@ -665,7 +665,7 @@ void Platform::setWindowSize( U32 newWidth, U32 newHeight )
//------------------------------------------------------------------------------
void Platform::initWindow(const Point2I &initialSize, const char *name)
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
// initialize window
InitWindow(initialSize, name);
if (!InitOpenGL())
@ -825,7 +825,7 @@ int main(S32 argc, const char **argv)
void Platform::setWindowTitle( const char* title )
{
#ifndef DEDICATED
#ifndef TORQUE_DEDICATED
x86UNIXState->setWindowName(title);
SDL_WM_SetCaption(x86UNIXState->getWindowName(), NULL);
#endif