Quake Source Code Analysis (Draft) .1

xiaoxiao2021-03-06  66

Quake is the world's global FPS game. So far, it has developed to the third generation, and as an excellent game engine, it is also used to use to other company developed games. For example we are familiar CS, it is improved on the quake2 engine. Although the code is not exactly the same, the overall frame is still quake2, as long as it is slightly touched by the Quake engine, it is easy to see. (It is Then the classic, so that I have been using today, I think it is a model for large structured design in the game field. Now many games have been written in object-oriented programming methods, but the impact of quake is far-reaching The CS2 source code that is leaked for some time, and its architecture still retains many quake style.)

Many people tell me that Id Software has already publicized the QUAKE 3 all the source code. Here I want to tell everyone, in fact, the ID is not all source code, but only the logical layer code, you think of which company you want to see Will be stupid to pour your own core technology, but they eat the capital! The logical layer code only includes Ui, Ai et al., And the network transfer portion is not given. You see Only the function of the function. Therefore, it is necessary to complete the QUAKE3 must obtain this part of the source code. Can you find it? It is exciting that there have been a koas in the early morning, the QUAKE3 core code will be organized. Come out, I made an imitation quake3 engine (Dusk3D). The following analysis is written according to his code, although there may be some access to the real Quake3 engine, but I believe that it does not affect QUAKE3.

Classs such as win32 applications, Quake's Win32 part is also entered from the Winmain function. The logic layer is divided into four major modules of CGAME, GAME, UI, Q3_UI. (These modules are made into a DLL program, by the engine Negatively loading them) The interaction between the DLL and the engine is completed by VMMain and DLlentry.

VMMAIN As the engine program to access the logical layer DLL interface, the engine uses the VM_Call function to call the VMMAIN that the logic layer DLL is introduced, and the VMMAIN looks up to the corresponding function implementation based on the index number of the function provided by the engine.

DLlentry is an interface for the logical layer DLL receiving engine system function. The logical layer DLL uses its call engine to provide to his system function.

SV_GameSystemCalls is the system function call interface for the engine to provide the GAME module. CGAMESystemCalls is provided to the CGAME module, and Cl_uiSystemCalls is provided to the UI module. The implementation method of these functions is very similar to Vmmain, which is based on a Switch statement The incoming index number jumps to the specified function.

The following is the implementation of the DLlentry function, you can see that it has only one parameter, a function pointer, this function pointer is an interface function that the engine is provided to the logical layer module, such as SV_GameSystemCalls:

Static int (cdecl * syscall) (int arg, ...) = (int, ...) - 1;

Void DLLENTRY (int (cdecl * syscallptr) (int Arg, ...) {

Syscall = syscallptr;

}

The function of the common TRAP head is actually called the engine code, the specific:

Void trap_printf (const char * fmt) {

Syscall (g_print, fmt);

}

After understanding the call rules, we can easily track the debug quake source code.

转载请注明原文地址:https://www.9cbs.com/read-111570.html

New Post(0)