Example #1
0
void LUA_UnArchive(void)
{
	UINT32 mobjnum;
	INT32 i;
	thinker_t *th;

	if (gL)
		lua_newtable(gL); // tables to be read

	for (i = 0; i < MAXPLAYERS; i++)
	{
		if (!playeringame[i])
			continue;
		UnArchiveExtVars(&players[i]);
	}

	do {
		mobjnum = READUINT32(save_p); // read a mobjnum
		for (th = thinkercap.next; th != &thinkercap; th = th->next)
			if (th->function.acp1 == (actionf_p1)P_MobjThinker
			&& ((mobj_t *)th)->mobjnum == mobjnum) // find matching mobj
				UnArchiveExtVars(th); // apply variables
	} while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker.

	NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode
	UnArchiveTables();

	if (gL)
		lua_pop(gL, 1); // pop tables
}
Example #2
0
File: d_netfil.c Project: STJr/SRB2
/** Parses the serverinfo packet and fills the fileneeded table on client
  *
  * \param fileneedednum_parm The number of files needed to join the server
  * \param fileneededstr The memory block containing the list of needed files
  *
  */
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
{
	INT32 i;
	UINT8 *p;
	UINT8 filestatus;

	fileneedednum = fileneedednum_parm;
	p = (UINT8 *)fileneededstr;
	for (i = 0; i < fileneedednum; i++)
	{
		fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet
		filestatus = READUINT8(p); // The first byte is the file status
		fileneeded[i].willsend = (UINT8)(filestatus >> 4);
		fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size
		fileneeded[i].file = NULL; // The file isn't open yet
		READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name
		READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum
	}
}
Example #3
0
// convert doom format sound (signed 8bit)
// to an fmod format sound (unsigned 8bit)
// and return the FMOD_SOUND.
static inline FMOD_SOUND *ds2fmod(char *stream)
{
	FMOD_SOUND *sound;
	UINT16 ver;
	UINT16 freq;
	UINT32 samples;
	FMOD_CREATESOUNDEXINFO fmt;
	UINT32 i;
	UINT8 *p;

	// lump header
	ver = READUINT16(stream); // sound version format?
	if (ver != 3) // It should be 3 if it's a doomsound...
		return NULL; // onos! it's not a doomsound!
	freq = READUINT16(stream);
	samples = READUINT32(stream);
	//CONS_Printf("FMT: v%d f%d, s%d, b%d\n", ver, freq, samples, bps);

	memset(&fmt, 0, sizeof(FMOD_CREATESOUNDEXINFO));
	fmt.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);

	// convert to unsigned
	fmt.format = FMOD_SOUND_FORMAT_PCM8; // 8bit
	fmt.length = samples*1; // 1 bps
	fmt.numchannels = 1; // mono
	fmt.defaultfrequency = freq;

	// Make a duplicate of the stream to change format.
	p = Z_Malloc(fmt.length, PU_SOUND, NULL);
	for (i = 0; i < fmt.length; i++)
		p[i] = (UINT8)(stream[i]+0x80); // convert from signed to unsigned
	stream = (char *)p;

	// Create FMOD_SOUND.
	FMR(FMOD_System_CreateSound(fsys, stream, FMOD_CREATESAMPLE|FMOD_OPENMEMORY|FMOD_OPENRAW|FMOD_SOFTWARE|FMOD_LOWMEM, &fmt, &sound));

	Z_Free(stream); // FMOD made its own copy, so we don't need this anymore.
	return sound;
}
Example #4
0
static UINT8 UnArchiveValue(int TABLESINDEX)
{
	UINT8 type = READUINT8(save_p);
	switch (type)
	{
	case ARCH_NULL:
		lua_pushnil(gL);
		break;
	case ARCH_BOOLEAN:
		lua_pushboolean(gL, READUINT8(save_p));
		break;
	case ARCH_SIGNED:
		lua_pushinteger(gL, READFIXED(save_p));
		break;
	case ARCH_UNSIGNED:
		lua_pushinteger(gL, READANGLE(save_p));
		break;
	case ARCH_STRING:
	{
		char value[1024];
		READSTRING(save_p, value);
		lua_pushstring(gL, value);
		break;
	}
	case ARCH_TABLE:
	{
		UINT16 tid = READUINT16(save_p);
		lua_rawgeti(gL, TABLESINDEX, tid);
		if (lua_isnil(gL, -1))
		{
			lua_pop(gL, 1);
			lua_newtable(gL);
			lua_pushvalue(gL, -1);
			lua_rawseti(gL, TABLESINDEX, tid);
			return 2;
		}
		break;
	}
	case ARCH_MOBJINFO:
		LUA_PushUserdata(gL, &mobjinfo[READUINT16(save_p)], META_MOBJINFO);
		break;
	case ARCH_STATE:
		LUA_PushUserdata(gL, &states[READUINT16(save_p)], META_STATE);
		break;
	case ARCH_MOBJ:
		LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(save_p)), META_MOBJ);
		break;
	case ARCH_PLAYER:
		LUA_PushUserdata(gL, &players[READUINT8(save_p)], META_PLAYER);
		break;
	case ARCH_MAPTHING:
		LUA_PushUserdata(gL, &mapthings[READUINT16(save_p)], META_MAPTHING);
		break;
	case ARCH_VERTEX:
		LUA_PushUserdata(gL, &vertexes[READUINT16(save_p)], META_VERTEX);
		break;
	case ARCH_LINE:
		LUA_PushUserdata(gL, &lines[READUINT16(save_p)], META_LINE);
		break;
	case ARCH_SIDE:
		LUA_PushUserdata(gL, &sides[READUINT16(save_p)], META_SIDE);
		break;
	case ARCH_SUBSECTOR:
		LUA_PushUserdata(gL, &subsectors[READUINT16(save_p)], META_SUBSECTOR);
		break;
	case ARCH_SECTOR:
		LUA_PushUserdata(gL, &sectors[READUINT16(save_p)], META_SECTOR);
		break;
	case ARCH_MAPHEADER:
		LUA_PushUserdata(gL, &sectors[READUINT16(save_p)], META_MAPHEADER);
		break;
	case ARCH_TEND:
		return 1;
	}
	return 0;
}