Revert r5768 which got committed accidentily

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5772 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-08-03 23:09:33 +00:00
parent 7980737e77
commit ced8a64ad1
8 changed files with 2 additions and 221 deletions

View File

@ -36,7 +36,7 @@ noinst_HEADERS = action.h advvis.h ai.h aiexperience.h anim_id.h \
message.h messagedef.h messagely.h message_parser.tab.h miscimd.h \
mission.h missiondef.h move.h movedef.h \
multigifts.h multiint.h multijoin.h multilimit.h multimenu.h multiplay.h multirecv.h \
multistat.h mumblelink.h objectdef.h objects.h objmem.h oprint.h parsetest.h positiondef.h order.h \
multistat.h objectdef.h objects.h objmem.h oprint.h parsetest.h positiondef.h order.h \
orderdef.h power.h projectile.h radar.h raycast.h research.h \
researchdef.h scores.h scriptai.h scriptcb.h scriptextern.h scriptfuncs.h \
scriptobj.h scripttabs.h scriptvals.h selection.h seqdisp.h stats.h stats-db2.h statsdef.h \
@ -53,7 +53,7 @@ warzone2100_SOURCES = scriptvals_parser.tab.c scriptvals_lexer.lex.c \
loop.c main.c map.c mapdisplay.c mapgrid.c mechanics.c message.c \
message_lexer.lex.c message_parser.tab.c miscimd.c \
move.c multiint.c multimenu.c multiopt.c multisync.c multibot.c multistat.c \
mumblelink.c objmem.c objects.c order.c parsetest.c radar.c \
objmem.c objects.c order.c parsetest.c radar.c \
raycast.c research.c scores.c scriptai.c scriptcb.c scriptextern.c scriptfuncs.c \
scriptobj.c scripttabs.c scriptvals.c selection.c stats.c text.c texture.c \
transporter.c visibility.c warcam.c wrappers.c aud.c \

View File

@ -78,7 +78,6 @@
#include "modding.h"
#include "multigifts.h"
#include "multiplay.h"
#include "mumblelink.h"
#include "projectile.h"
#include "radar.h"
#include "lib/framework/cursors.h"
@ -436,8 +435,6 @@ BOOL systemInitialise(void)
return false;
}
InitMumbleLink();
// Initialize the iVis text rendering module
iV_TextInit();
@ -484,8 +481,6 @@ void systemShutdown(void)
fpathShutdown();
CloseMumbleLink();
return;
}

View File

@ -67,7 +67,6 @@
#include "loadsave.h"
#include "game.h"
#include "multijoin.h"
#include "mumblelink.h"
#include "lighting.h"
#include "intimage.h"
#include "lib/framework/cursors.h"
@ -149,7 +148,6 @@ GAMECODE gameLoop(void)
BOOL quitting=false;
INT_RETVAL intRetVal;
int clearMode = 0;
const Vector3f playerRot = Vector3f_ToRadians(Vector3iPSX_To3fDegree(player.r));
if (!war_GetFog())
{
@ -176,10 +174,6 @@ GAMECODE gameLoop(void)
audio_Update();
UpdateMumbleSoundPos(Vector3i_To3f(player.p),
Vector3f_EulerToForwardVector(playerRot),
Vector3f_EulerToUpVector(playerRot));
if (!paused)
{
if (!scriptPaused() && !editPaused())

View File

@ -59,7 +59,6 @@ SRC=ai.c \
multisync.c \
multibot.c \
multistat.c \
mumblelink.c \
objmem.c \
objects.c \
order.c \

View File

@ -1,174 +0,0 @@
#include "mumblelink.h"
#include "lib/framework/frame.h"
#include "lib/ivis_common/pievector.h"
#include <wchar.h>
typedef struct
{
uint32_t uiVersion;
int32_t uiTick;
Vector3f position;
Vector3f forward;
Vector3f up;
wchar_t name[256];
} LinkedMem;
#if defined(WZ_OS_UNIX)
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#include <time.h>
#endif
#if defined(WZ_OS_WIN)
typedef HANDLE FileHandle;
#define EMPTY_FILEHANDLE NULL
#define MAP_FAILED NULL
#elif defined(WZ_OS_UNIX)
typedef int FileHandle;
#define EMPTY_FILEHANDLE -1
#endif
static const FileHandle EmptyFileHandle = EMPTY_FILEHANDLE;
static FileHandle SharedMem = EMPTY_FILEHANDLE;
static LinkedMem* lm = NULL;
bool InitMumbleLink()
{
// When "doubly" initialising just say we're succesful
if (lm != NULL)
return true;
// Open shared memory (should be created by Mumble)
if (SharedMem == EmptyFileHandle)
{
#if defined(WZ_OS_WIN)
SharedMem = OpenFileMappingW(FILE_MAP_ALL_ACCESS, false, L"MumbleLink");
#elif defined(WZ_OS_UNIX)
char* memname;
sasprintf(&memname, "/MumbleLink.%d", (int)getuid());
SharedMem = shm_open(memname, O_RDWR, S_IRUSR | S_IWUSR);
#endif
if (SharedMem == EmptyFileHandle)
{
#if defined(WZ_OS_WIN)
debug(LOG_NEVER, "Failed to open a shared memory object: %d", GetLastError());
#elif defined(WZ_OS_UNIX)
debug(LOG_NEVER, "Failed to open a shared memory object: %s", strerror(errno));
#endif
return false;
}
}
// Map a LinkedMem instance onto shared memory
if (lm == NULL)
{
#if defined(WZ_OS_WIN)
lm = (LinkedMem *)MapViewOfFile(SharedMem, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*lm));
#elif defined(WZ_OS_UNIX)
lm = (LinkedMem *)mmap(NULL, sizeof(*lm), PROT_READ | PROT_WRITE, MAP_SHARED, SharedMem, 0);
#endif
if (lm == MAP_FAILED)
{
#if defined(WZ_OS_WIN)
debug(LOG_ERROR, "Failed to map shared memory into local memory: %d", GetLastError());
#elif defined(WZ_OS_UNIX)
debug(LOG_ERROR, "Failed to map shared memory into local memory: %s", strerror(errno));
lm = NULL;
#endif
return false;
}
}
wcsncpy(lm->name, L"Warzone 2100", sizeof(lm->name));
// Guarantee to NUL terminate
lm->name[sizeof(lm->name) - 1] = L'\0';
return true;
}
#if defined(WZ_OS_WIN)
#elif defined(WZ_OS_UNIX)
#endif
bool CloseMumbleLink()
{
if (lm != NULL)
{
#if defined(WZ_OS_WIN)
const bool success = UnmapViewOfFile(lm);
#elif defined(WZ_OS_UNIX)
const bool success = (munmap(lm, sizeof(*lm)) == 0);
#endif
if (!success)
{
#if defined(WZ_OS_WIN)
debug(LOG_ERROR, "Failed to unmap shared memory out of local memory: %d", GetLastError());
#elif defined(WZ_OS_UNIX)
debug(LOG_ERROR, "Failed to unmap shared memory out of local memory: %s", strerror(errno));
#endif
return false;
}
lm = NULL;
}
if (SharedMem != EmptyFileHandle)
{
#if defined(WZ_OS_WIN)
const bool success = CloseHandle(SharedMem);
#elif defined(WZ_OS_UNIX)
const bool success = (close(SharedMem) == 0);
#endif
if (!success)
{
#if defined(WZ_OS_WIN)
debug(LOG_ERROR, "Failed to close a shared memory object: %d", GetLastError());
#elif defined(WZ_OS_UNIX)
debug(LOG_ERROR, "Failed to close a shared memory object: %s", strerror(errno));
#endif
return false;
}
SharedMem = EmptyFileHandle;
}
return true;
}
#if defined(WZ_OS_UNIX)
static const int32_t GetTickCount(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
const int32_t milliSeconds = tv.tv_usec / 1000 + tv.tv_sec * 1000;
return milliSeconds;
}
#endif
bool UpdateMumbleSoundPos(const Vector3f pos, const Vector3f forward, const Vector3f up)
{
if (lm == NULL)
{
return false;
}
lm->position = pos;
lm->forward = Vector3f_Normalise(forward);
lm->up = Vector3f_Normalise(up);
// Protocol version of Mumble's "Link" plugin
lm->uiVersion = 1;
/* This is used to indicate that this data has been updated. Thus to
* avoid locking conflicts it must be the last change we do to this
* structure.
*/
lm->uiTick = GetTickCount();
return true;
}

View File

@ -1,12 +0,0 @@
#ifndef __INCLUDED_SRC_MUMBLELINK_H__
#define __INCLUDED_SRC_MUMBLELINK_H__
#include "lib/framework/frame.h"
#include "lib/ivis_common/pievector.h"
extern bool InitMumbleLink(void);
extern bool CloseMumbleLink(void);
extern bool UpdateMumbleSoundPos(const Vector3f pos, const Vector3f forward, const Vector3f up);
#endif // __INCLUDED_SRC_MUMBLELINK_H__

View File

@ -2385,19 +2385,6 @@
<Option target="DBGWindows" />
<Option target="NDBGWindows" />
</Unit>
<Unit filename="src/mumblelink.c">
<Option compilerVar="CC" />
<Option target="DBGUnix" />
<Option target="NDBGUnix" />
<Option target="DBGWindows" />
<Option target="NDBGWindows" />
</Unit>
<Unit filename="src/mumblelink.h">
<Option target="DBGUnix" />
<Option target="NDBGUnix" />
<Option target="DBGWindows" />
<Option target="NDBGWindows" />
</Unit>
<Unit filename="src/objectdef.h">
<Option target="DBGUnix" />
<Option target="NDBGUnix" />

View File

@ -524,10 +524,6 @@
RelativePath="..\src\multisync.c"
>
</File>
<File
RelativePath="..\src\mumblelink.c"
>
</File>
<File
RelativePath="..\src\objects.c"
>
@ -1031,10 +1027,6 @@
RelativePath="..\src\multistat.h"
>
</File>
<File
RelativePath="..\src\mumblelink.h"
>
</File>
<File
RelativePath="..\src\objectdef.h"
>