コード例 #1
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CRecordingEngExtInterceptor::SteamAPI_UnregisterCallResult(class CCallbackBase *pCallback, SteamAPICall_t hAPICall)
{
	CSteamCallbackRecordingWrapper* wrappee = getOrCreateCallbackWrapper(pCallback);

	if (wrappee->GetFlags() != pCallback->GetFlags()) rehlds_syserror("%s: flags desync", __FUNCTION__);
	if (wrappee->GetICallback() != pCallback->GetICallback()) rehlds_syserror("%s: flags desync", __FUNCTION__);

	CSteamApiUnrigestierCallResultCall fcall(wrappee->getRehldsCallbackId(), hAPICall, wrappee); CRecorderFuncCall frec(&fcall);
	
	PushFunc(&frec);
	
	m_BasePlatform->SteamAPI_UnregisterCallResult(wrappee, hAPICall);
	
	fcall.setResult(wrappee);
	pCallback->SetFlags(wrappee->GetFlags());
	pCallback->SetICallback(wrappee->GetICallback());

	PopFunc(&frec);
}
コード例 #2
0
IGameClient* GetRehldsApiClient(client_t* cl)
{
	int idx = cl - g_psvs.clients;
	if (idx < 0 || idx >= g_psvs.maxclients)
	{
		rehlds_syserror(__FUNCTION__": Invalid client index %d", idx);
	}

	return g_GameClients[idx];
}
コード例 #3
0
CRehldsFlightRecorder::CRehldsFlightRecorder() {
	m_MetaRegion = (uint8*) sys_allocmem(META_REGION_SIZE);
	m_DataRegion = (uint8*) sys_allocmem(DATA_REGION_SIZE);

	if (!m_MetaRegion || !m_DataRegion) {
		rehlds_syserror("%s: direct allocation failed", __FUNCTION__);
	}

	//initialize meta region header
	char* metaPos = (char*)m_MetaRegion;
	const char* metaSignature = "REHLDS_FLIGHTREC_META";
	metaPos += sprintf(metaPos, "%s%s%s:", metaSignature, metaSignature, metaSignature);

	m_pMetaHeader = (meta_header*)metaPos;
	metaPos += sizeof(meta_header);
	m_pRecorderState = (recorder_state*)metaPos;
	metaPos += sizeof(recorder_state);

	if ((metaPos - (char*)m_MetaRegion) > META_REGION_HEADER) {
		rehlds_syserror("%s: Meta header overflow", __FUNCTION__);
	}

	//initialize data region header
	char* dataPos = (char*)m_DataRegion;
	const char* dataSignature = "REHLDS_FLIGHTREC_DATA";
	dataPos += sprintf(dataPos, "%s%s%s:", dataSignature, dataSignature, dataSignature);

	m_pDataHeader = (data_header*)dataPos;
	dataPos += sizeof(data_header);

	if ((dataPos - (char*)m_pDataHeader) > DATA_REGION_HEADER) {
		rehlds_syserror("%s: Data header overflow", __FUNCTION__);
	}

	InitHeadersContent();

	m_MetaRegionPtr = m_MetaRegion + META_REGION_HEADER;
	m_DataRegionPtr = m_DataRegion + DATA_REGION_HEADER;
}
コード例 #4
0
void CRehldsFlightRecorder::StartMessage(uint16 msg, bool entrance) {
	if (msg == 0 || msg > m_pMetaHeader->numMessages) {
		rehlds_syserror("%s: Invalid message id %u", __FUNCTION__, msg);
	}

	if (entrance) {
		msg = msg | 0x8000;
	}

	if (m_pRecorderState->curMessage != 0) {
		rehlds_syserror("%s: overlapping messages", __FUNCTION__);
	}

	unsigned int sz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
	if (sz < 6) {
		MoveToStart();
	}

	m_pRecorderState->curMessage = msg;
	m_pRecorderState->lastMsgBeginPos = m_pRecorderState->wpos;
	*(uint16*)(m_DataRegionPtr + m_pRecorderState->wpos) = msg;
	m_pRecorderState->wpos += 2;
}
コード例 #5
0
void CRehldsFlightRecorder::EndMessage(uint16 msg, bool entrance) {
	if (entrance) {
		msg = msg | 0x8000;
	}

	if (m_pRecorderState->curMessage != msg) {
		rehlds_syserror("%s: invalid message %u", __FUNCTION__, msg);
	}

	unsigned int freeSz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
	if (freeSz < 2) {
		MoveToStart();
	}

	unsigned int msgSize = m_pRecorderState->wpos - m_pRecorderState->lastMsgBeginPos;
	if (msgSize > MSG_MAX_SIZE) {
		rehlds_syserror("%s: too big message %u; size%u", __FUNCTION__, msg, msgSize);
	}
	*(uint16*)(m_DataRegionPtr + m_pRecorderState->wpos) = msgSize;
	m_pRecorderState->wpos += 2;

	m_pRecorderState->curMessage = 0;
}
コード例 #6
0
void CRehldsFlightRecorder::WriteBuffer(const void* data, unsigned int len) {
	if (m_pRecorderState->curMessage == 0) {
		rehlds_syserror("%s: Could not write, invalid state", __FUNCTION__);
	}

	CheckSize(len);
	unsigned int freeSz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
	if (freeSz < len) {
		MoveToStart();
	}

	memcpy(m_DataRegionPtr + m_pRecorderState->wpos, data, len);
	m_pRecorderState->wpos += len;
}
コード例 #7
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CRecordingEngExtInterceptor::PopFunc(CRecorderFuncCall* func)
{
	if (func != m_LastFunc)
		rehlds_syserror("%s: stack corrupted", __FUNCTION__);

	writeCall(!func->m_StartWritten, true, func->m_FuncCall);
	if (m_LastFunc->m_Prev == NULL) {
		m_LastFunc = m_RootFunc = NULL;
	}
	else
	{
		m_LastFunc = m_LastFunc->m_Prev;
		m_LastFunc->m_Next = NULL;
	}
}
コード例 #8
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
bool CSteamAppsRecordingWrapper::BIsVACBanned()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return false;
}
コード例 #9
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
HAuthTicket CSteamGameServerRecordingWrapper::GetAuthSessionTicket(void *pTicket, int cbMaxTicket, uint32 *pcbTicket)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_HAuthTicketInvalid;
}
コード例 #10
0
ファイル: net_chan.cpp プロジェクト: Chuvi-w/rehlds
int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *filename)
#endif // REHLDS_FIXES
{
	int chunksize;
	int compressedFileTime;
	FileHandle_t hfile;
	signed int filesize;
	int remaining;
	fragbufwaiting_t *p;
	int send;
	fragbuf_t *buf;
	char compressedfilename[MAX_PATH];
	qboolean firstfragment;
	int bufferid;
	qboolean bCompressed;
	int pos;
	fragbufwaiting_t *wait;
	int uncompressed_size;

	bufferid = 1;
	firstfragment = TRUE;
	bCompressed = FALSE;
	chunksize = chan->pfnNetchan_Blocksize(chan->connection_status);

	Q_snprintf(compressedfilename, sizeof compressedfilename, "%s.ztmp", filename);
	compressedFileTime = FS_GetFileTime(compressedfilename);
	if (compressedFileTime >= FS_GetFileTime(filename) && (hfile = FS_Open(compressedfilename, "rb")))
	{
		filesize = FS_Size(hfile);
		FS_Close(hfile);
		bCompressed = TRUE;
		hfile = FS_Open(filename, "rb");
		if (!hfile)
		{
			Con_Printf("Warning:  Unable to open %s for transfer\n", filename);
			return 0;
		}

		uncompressed_size = FS_Size(hfile);
		if (uncompressed_size > sv_filetransfermaxsize.value)
		{
			FS_Close(hfile);
			Con_Printf("Warning:  File %s is too big to transfer from host %s\n", filename, NET_AdrToString(chan->remote_address));
			return 0;
		}
	}
	else
	{
		hfile = FS_Open(filename, "rb");
		if (!hfile)
		{
			Con_Printf("Warning:  Unable to open %s for transfer\n", filename);
			return 0;
		}
		filesize = FS_Size(hfile);
		if (filesize > sv_filetransfermaxsize.value)
		{
			FS_Close(hfile);
			Con_Printf("Warning:  File %s is too big to transfer from host %s\n", filename, NET_AdrToString(chan->remote_address));
			return 0;
		}

		uncompressed_size = filesize;
		if (sv_filetransfercompression.value != 0.0)
		{
			unsigned char* uncompressed = (unsigned char*)Mem_Malloc(filesize);
			unsigned char* compressed = (unsigned char*)Mem_Malloc(filesize);
			unsigned int compressedSize = filesize;
			FS_Read(uncompressed, filesize, 1, hfile);
			if (BZ_OK == BZ2_bzBuffToBuffCompress((char*)compressed, &compressedSize, (char*)uncompressed, filesize, 9, 0, 30))
			{
				FileHandle_t destFile = FS_Open(compressedfilename, "wb");
				if (destFile)
				{
					Con_DPrintf("Creating compressed version of file %s (%d -> %d)\n", filename, filesize, compressedSize);
					FS_Write(compressed, compressedSize, 1, destFile);
					FS_Close(destFile);
					filesize = compressedSize;
					bCompressed = TRUE;
				}
			}
			Mem_Free(uncompressed);
			Mem_Free(compressed);
		}
	}
	FS_Close(hfile);

	wait = (fragbufwaiting_t *)Mem_ZeroMalloc(0xCu);
	remaining = filesize;
	pos = 0;

	while (remaining)
	{
		send = min(chunksize, remaining);
		buf = Netchan_AllocFragbuf();
		if (!buf)
		{
			Con_Printf("Couldn't allocate fragbuf_t\n");
			Mem_Free(wait);
			if (server)
			{
#ifdef REHLDS_FIXES
				SV_DropClient(&g_psvs.clients[chan->player_slot - 1], 0, "Malloc problem");
#else // REHLDS_FIXES
				SV_DropClient(host_client, 0, "Malloc problem");
#endif // REHLDS_FIXES
				return 0;
			}
			else
			{
				rehlds_syserror("%s: Reverse clientside code", __func__);
				//return 0;
			}
		}

		buf->bufferid = bufferid++;
		SZ_Clear(&buf->frag_message);
		if (firstfragment)
		{
			firstfragment = FALSE;
			MSG_WriteString(&buf->frag_message, filename);
			MSG_WriteString(&buf->frag_message, bCompressed ? "bz2" : "uncompressed");
			MSG_WriteLong(&buf->frag_message, uncompressed_size);
			send -= buf->frag_message.cursize;
		}
		buf->isfile = TRUE;
		buf->iscompressed = bCompressed;
		buf->size = send;
		buf->foffset = pos;

		Q_strncpy(buf->filename, filename, MAX_PATH - 1);
		buf->filename[MAX_PATH - 1] = 0;

		pos += send;
		remaining -= send;

		Netchan_AddFragbufToTail(wait, buf);
	}

	if (!chan->waitlist[FRAG_FILE_STREAM])
	{
		chan->waitlist[FRAG_FILE_STREAM] = wait;
	}
	else
	{
		p = chan->waitlist[FRAG_FILE_STREAM];
		while (p->next)
			p = p->next;

		p->next = wait;
	}

	return 1;
}
コード例 #11
0
ファイル: testsuite.cpp プロジェクト: Chuvi-w/rehlds
ISteamHTTP* __cdecl SteamHTTP_hooked()
{
	rehlds_syserror("%s: not implemented", __func__);
	//return NULL;
}
コード例 #12
0
ファイル: testsuite.cpp プロジェクト: Chuvi-w/rehlds
void __cdecl SteamAPI_Shutdown_hooked()
{
	rehlds_syserror("%s: not implemented", __func__);
}
コード例 #13
0
ファイル: testsuite.cpp プロジェクト: Chuvi-w/rehlds
void __cdecl SteamAPI_SetMiniDumpComment_hooked(const char *pchMsg)
{
	rehlds_syserror("%s: not implemented", __func__);
}
コード例 #14
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CSteamGameServerRecordingWrapper::GetGameplayStats()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
コード例 #15
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
bool CSteamGameServerRecordingWrapper::RequestUserGroupStatus(CSteamID steamIDUser, CSteamID steamIDGroup)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return false;
}
コード例 #16
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
EUserHasLicenseForAppResult CSteamGameServerRecordingWrapper::UserHasLicenseForApp(CSteamID steamID, AppId_t appID)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_EUserHasLicenseResultDoesNotHaveLicense;
}
コード例 #17
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CSteamGameServerRecordingWrapper::CancelAuthTicket(HAuthTicket hAuthTicket)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
コード例 #18
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CSteamGameServerRecordingWrapper::EndAuthSession(CSteamID steamID)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
コード例 #19
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
EBeginAuthSessionResult CSteamGameServerRecordingWrapper::BeginAuthSession(const void *pAuthTicket, int cbAuthTicket, CSteamID steamID)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_EBeginAuthSessionResultInvalidTicket;
}
コード例 #20
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CSteamGameServerRecordingWrapper::SetGameData(const char *pchGameData)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
コード例 #21
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
const char* CSteamAppsRecordingWrapper::GetAvailableGameLanguages()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return NULL;
}
コード例 #22
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
SteamAPICall_t CSteamGameServerRecordingWrapper::GetServerReputation()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_uAPICallInvalid;
}
コード例 #23
0
ファイル: testsuite.cpp プロジェクト: Chuvi-w/rehlds
void __cdecl SteamAPI_WriteMiniDump_hooked(uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID)
{
	rehlds_syserror("%s: not implemented", __func__);
}
コード例 #24
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
uint32 CSteamGameServerRecordingWrapper::GetPublicIP()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return 0;
}
コード例 #25
0
ファイル: testsuite.cpp プロジェクト: Chuvi-w/rehlds
void __cdecl SteamAPI_RegisterCallResult_hooked(class CCallbackBase *pCallback, SteamAPICall_t hAPICall)
{
	rehlds_syserror("%s: not implemented", __func__);
}
コード例 #26
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
SteamAPICall_t CSteamGameServerRecordingWrapper::AssociateWithClan(CSteamID steamIDClan)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_uAPICallInvalid;
}
コード例 #27
0
ファイル: net_chan.cpp プロジェクト: Chuvi-w/rehlds
void Netchan_CreateFileFragmentsFromBuffer(qboolean server, netchan_t *chan, const char *filename, unsigned char *uncompressed_pbuf, int uncompressed_size)
{
	int chunksize;
	int send;
	fragbufwaiting_t *p;
	fragbuf_t *buf;
	unsigned char *pbuf;
	qboolean bCompressed;
	qboolean firstfragment;
	signed int bufferid;
	int remaining;
	int pos;
	unsigned int size;
	fragbufwaiting_t *wait;

	if (!uncompressed_size)
		return;

	bufferid = 1;
	firstfragment = TRUE;
	size = uncompressed_size;

	pbuf = (unsigned char *)Mem_Malloc(uncompressed_size);
	if (BZ2_bzBuffToBuffCompress((char*)pbuf, &size, (char*)uncompressed_pbuf, uncompressed_size, 9, 0, 30))
	{
		bCompressed = FALSE;
		Mem_Free(pbuf);
		pbuf = uncompressed_pbuf;
		size = uncompressed_size;
	}
	else
	{
		bCompressed = TRUE;
		Con_DPrintf("Compressed %s for transmission (%d -> %d)\n", filename, uncompressed_size, size);
	}

	chunksize = chan->pfnNetchan_Blocksize(chan->connection_status);
	send = chunksize;
	wait = (fragbufwaiting_t *)Mem_ZeroMalloc(0xCu);
	remaining = size;
	pos = 0;

	while (remaining > 0)
	{
		send = min(remaining, chunksize);
		buf = (fragbuf_t *)Netchan_AllocFragbuf();
		if (!buf)
		{
			Con_Printf("Couldn't allocate fragbuf_t\n");
			Mem_Free(wait);
			if (server)
				SV_DropClient(host_client, 0, "Malloc problem");
			else
				rehlds_syserror("%s:Reverse me: client-side code", __func__);

#ifdef REHLDS_FIXES
			if (bCompressed) {
				Mem_Free(pbuf);
			}
#endif
			return;
		}

		buf->bufferid = bufferid++;
		SZ_Clear(&buf->frag_message);
		if (firstfragment)
		{
			firstfragment = FALSE;
			MSG_WriteString(&buf->frag_message, filename);
			MSG_WriteString(&buf->frag_message, bCompressed ? "bz2" : "uncompressed");
			MSG_WriteLong(&buf->frag_message, uncompressed_size);
			send -= buf->frag_message.cursize;
		}

		buf->isbuffer = TRUE;
		buf->isfile = TRUE;
		buf->size = send;
		buf->foffset = pos;

		MSG_WriteBuf(&buf->frag_message, send, &pbuf[pos]);
		pos += send;
		remaining -= send;

		Netchan_AddFragbufToTail(wait, buf);
	}

	if (!chan->waitlist[FRAG_FILE_STREAM]) {
		chan->waitlist[FRAG_FILE_STREAM] = wait;
	}
	else
	{
		p = chan->waitlist[FRAG_FILE_STREAM];
		while (p->next)
			p = p->next;

		p->next = wait;
	}

#ifdef REHLDS_FIXES
	if (bCompressed) {
		Mem_Free(pbuf);
	}
#endif
}
コード例 #28
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
SteamAPICall_t CSteamGameServerRecordingWrapper::ComputeNewPlayerCompatibility(CSteamID steamIDNewPlayer)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
	return k_uAPICallInvalid;
}
コード例 #29
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CSteamGameServerRecordingWrapper::ForceHeartbeat()
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}
コード例 #30
0
ファイル: recorder.cpp プロジェクト: ChunHungLiu/rehlds
void CSteamGameServerRecordingWrapper::SetRegion(const char *pszRegion)
{
	rehlds_syserror("%s: not implemented", __FUNCTION__);
}