bool zGlobalHk::PlaceWndHook(HWND hwnd)
{
	GET_HOOK(zGlobalHk).m_AppWndProc = GetWindowLongPtrA(hwnd, GWL_WNDPROC);
	SetWindowLongPtrA(hwnd, GWL_WNDPROC, (LONG)AppWndProc);

	return true;
}
void zCModelMeshLibHk::zCModelMeshLib__BuildFromModelProto(zCModelMeshLib* thisptr, void* edx, zCModelPrototype* model)
{
	// This sets the meshlibs and finishes up model initialization
	GET_HOOK(zCModelMeshLibHk).m_BuildFromModelProto(thisptr, model);

	InitMeshLib(thisptr);
}
/**
* Called whenever a vob moved
*/
void __fastcall zCVobHk::zCVob__EndMovement(zCVob* thisptr, void* edx, zBOOL transformChanged)
{
	GVobObject* vobj = thisptr->GetVobObject();
	GVobObject* vobjq = GVobObject::QueryFromSource(thisptr);
	//if(vobj != vobjq)
	//	LogWarn() << "zCVob has wrong pointer to GVobObject!";

	// PB didn't use this parameter really carefully. It's way faster to simply check the transform
	// a couple of times more than needed. Vobs for particles have this set to true for example, even if they 
	// don't really need it!
	if(transformChanged && vobj && vobj->GetWorldMatrix() == thisptr->GetWorldMatrix())
	{
		transformChanged = FALSE;	
	}

	GET_HOOK(zCVobHk).m_EndMovement(thisptr, transformChanged);

	/*__try{
		GET_HOOK(zCVobHk).m_EndMovement(thisptr, transformChanged);
	}
	__except(true)
	{
		auto fn = [](){LogWarn() << "Exception while EndMovement!";};
		fn();
	}*/
	// G2 actually checks if the transforms changed and passes this as parameter
	// But not always, so do another check. Also G1 doesn't check this at all
	if (vobj && (transformChanged || vobj->GetWorldMatrix() != thisptr->GetWorldMatrix()))
	{
		vobj->UpdateVob();
	}
}
/**
* Applications main-windows message callback
*/
LRESULT CALLBACK zGlobalHk::AppWndProc(HWND hwnd, DWORD msg, WPARAM wParam, LPARAM lParam)
{
	// Call our own proc-code
	Engine::Game->OnWindowMessage(hwnd, msg, wParam, lParam);

	// Call the games wnd-proc
	return CallWindowProc((WNDPROC)GET_HOOK(zGlobalHk).m_AppWndProc, hwnd, msg, wParam, lParam);
}
zBOOL zCModelMeshLibHk::zCModelMeshLib__LoadMDM(zCFileBIN& file, zCModelPrototype* proto, zCModel* model, zCModelMeshLib** lib)
{
	zBOOL r = GET_HOOK(zCModelMeshLibHk).m_LoadMDM(file, proto, model, lib);

	if(lib)
		InitMeshLib(*lib);

	return r;
}
/**
* Called whenever a vob moved
*/
void __fastcall zCVobHk::zCVob__EndMovement(zCVob* thisptr, void* edx)
{
	GET_HOOK(zCVobHk).m_EndMovement(thisptr);

	// Check if the vob actually changed. G1 calls this function for all vobs, even if it
	// didn't change anything
	if (thisptr->GetVobObject() && thisptr->GetVobObject()->GetWorldMatrix() != thisptr->GetWorldMatrix())
	{
		thisptr->GetVobObject()->UpdateVob();
	}
}
Beispiel #7
0
void
gth_hook_invoke (const char *name,
		 gpointer    first_data,
		 ...)
{
	GthHook         *hook;
	gpointer        *marshal_data;
	int              i = 0;
	va_list          args;
	GHookMarshaller  invoke_marshaller;

	hook = GET_HOOK (name);
	marshal_data = g_new0 (gpointer, hook->n_args);

	if (hook->n_args > 0) {
		marshal_data[i++] = first_data;
		va_start (args, first_data);
		while (i < hook->n_args)
			marshal_data[i++] = va_arg (args, gpointer);
		va_end (args);
	}

	switch (hook->n_args) {
	case 0:
		invoke_marshaller = invoke_marshaller_0;
		break;
	case 1:
		invoke_marshaller = invoke_marshaller_1;
		break;
	case 2:
		invoke_marshaller = invoke_marshaller_2;
		break;
	case 3:
		invoke_marshaller = invoke_marshaller_3;
		break;
	case 4:
		invoke_marshaller = invoke_marshaller_4;
		break;
	default:
		invoke_marshaller = NULL;
		break;
	}

	g_mutex_lock (&hook->mutex);
	if (invoke_marshaller != NULL)
		g_hook_list_marshal (hook->list, TRUE, invoke_marshaller, marshal_data);
	g_mutex_unlock (&hook->mutex);

	g_free (marshal_data);
}
Beispiel #8
0
void
gth_hook_remove_callback (const char *name,
			  GCallback   callback)
{
	GthHook *hook;
	GHook   *function;

	hook = GET_HOOK (name);
	function = g_hook_find_func (hook->list, TRUE, callback);
	if (function == NULL) {
		g_warning ("callback not found in hook '%s'", name);
		return;
	}
	g_hook_destroy_link (hook->list, function);
}
/** Called when this vob is about to change the visual */
void __fastcall zCVobHk::zCVob__SetVisual(zCVob* thisptr, void* edx, zCVisual* visual)
{
	if(!visual && thisptr->GetVobObject())
	{
		GWorld* wld = GWorld::QueryFromSource(thisptr->GetHomeWorld());

		if(wld)
		{
			wld->RemoveVob(thisptr);

			// Remove vob from world
			delete thisptr->GetVobObject();
		}
	}

	GET_HOOK(zCVobHk).m_SetVisual(thisptr, visual);
}
Beispiel #10
0
void
gth_hook_add_callback (const char *name,
		       int         sort_order,
		       GCallback   callback,
		       gpointer    data)
{
	GthHook *hook;
	GHook   *function;

	hook = GET_HOOK (name);

	function = g_hook_alloc (hook->list);
	function->func = callback;
	function->data = data;
	function->destroy = NULL;
	GTH_HOOK_CALLBACK (function)->sort_order = sort_order;

	g_hook_insert_sorted (hook->list, function, hook_compare_func);
}