void correctLocation(int currentNode, Location* currentLocation, int* orientation, Location mazeCoords[]) {
	correctSide(currentNode, currentLocation, orientation, mazeCoords, 5);
	correctFront(currentNode, currentLocation, orientation, mazeCoords);
}
Example #2
0
static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &/*identity*/) {
	for (int i=0;i<3;i++)
		avatar_pos[i]=avatar_front[i]=avatar_top[i]=0.0f;

	char state;
	bool ok;

	ok = peekProc((BYTE *) pModule+0x290557, state); // Magical state value
	if (! ok)
		return false;

	if (state != 8) {
		context.clear();
		return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
	}

	// Create containers to stuff our raw data into, so we can convert it to Mumble's coordinate system
	float pos_corrector[3];
	float front_corrector[3];
	float top_corrector[3];

	// Peekproc and assign game addresses to our containers, so we can retrieve positional data
	ok = peekProc((BYTE *) posptr, pos_corrector) &&
	     peekProc((BYTE *) frtptr, front_corrector) &&
	     peekProc((BYTE *) topptr, top_corrector);

	if (! ok)
		return false;
	
	// Convert to left-handed coordinate system

	avatar_pos[0] = -pos_corrector[0];
	avatar_pos[1] = pos_corrector[2];
	avatar_pos[2] = pos_corrector[1];

	for (int i=0;i<3;i++)
		avatar_pos[i] /= 64.0f; // Scale to meters

	avatar_front[0] = -front_corrector[1];
	avatar_front[1] = front_corrector[2];
	avatar_front[2] = -front_corrector[0];
	
	avatar_top[0] = top_corrector[0];
	avatar_top[1] = -top_corrector[2];
	avatar_top[2] = -top_corrector[1];

	correctFront(avatar_front, avatar_top);
	
	for (int i=0;i<3;i++) {
		camera_pos[i] = avatar_pos[i];
		camera_front[i] = avatar_front[i];
		camera_top[i] = avatar_top[i];
	}

	// Read server name
	BYTE *cbase = peekProc<BYTE *> ((BYTE *) pModule + 0x00290550);
	BYTE *cptr0 = peekProc<BYTE *> ((BYTE *) cbase + 0x30);
	BYTE *cptr1 = peekProc<BYTE *> ((BYTE *) cptr0 + 0x73C);
	BYTE *cptr2 = peekProc<BYTE *> ((BYTE *) cptr1 + 0x244);


	wchar_t wservername[60];

	ok = peekProc((BYTE *) cptr2, wservername);
	if (! ok)
		return false;

	wservername[sizeof(wservername)/sizeof(wservername[0]) - 1] = '\0';

	std::string servername;
	wcsToMultibyteStdString(wservername, servername);

	std::ostringstream contextss;
	contextss << "{"
	<< "\"servername\":\"" << servername << "\""
	<< "}";

	context = contextss.str();

	return true;
}