Quake Source Code Reading Analysis (2)

xiaoxiao2021-04-09  558

QUAKE3 source code analysis of the second ---- Continue to touch :)

I hope someone will read QUAKE3 with me. Send an email to discuss discussions, otherwise I have nothing to do!

1. By reading the source code of Quake3, a naming rule is discovered: the function name is related to the file name, such as the function declaration in the common.h file declares, like a Void COM_ENDREDIRECT (Void), such as CL_Main. The function declaration in the C file must be at the beginning of CL_, like qbolean cl_cdkeyvalidate (const char * key, const char * checksum); there is such a statement in ui_main.c: uiinfo_t uiinfo; (outside of all functions, it can be As a global variable is used in ui_local.h, there is a description: Extern UIInfo_t uiinfo; indicates that all other files containing the UI_Local.h file can use UIInfo variables. For example, ui_atoms The .C file contains the ui_local.h file, and can be used directly in the UI_AToms.c file. Why don't you use this variable in this file? My understanding is like this, The data structure of the declaration in ui_local.h is repeated in many files, like UIInfo. All will put them directly in ui_local.h without having to use extern. 2, How to use other modules in the Quake3 project? There is such a set of definitions including header files in Client.h: #include "../game/q_shared.h" #include "../qcommon/qcommon.h "#Include" ../renderer/tr_public.h "#include" ../ui/UI_PUBLIC.H "#include" keys.h "#include" SND_PUBLIC.H "#include" .. /cgame/cg_public.h "#Include" ../game/bg_public.h "This means that in the QUAKE3 main program, the resource in other modules is declared through these headers. To read quake3, you should know at least in these headers. What can you do. 3, analyze the event cycle function in_frame () is used for Capture the event generated by this machine. It is mainly to obtain an input event and mouse input event. COM_EVENTLOOP () Sys_GETPACKET function is used to obtain network data commands. 4. Why pack Memcpy () and MEMSET Function? By observing the source code, this is to enhance the transplantability of the program. When the 32-bit CPU becomes 64-bit CPU, it can directly get it directly. 5, quake3 network communication part is outside, work together with the main program, It doesn't bundle it as a DLL. The network part seems very simple. Void net_init (void): Network initialization section. Import the Winsock library, register a series of variables, configure the network communication .NET_OpenIP () function, with the current IP address The port is initialized for a certain mouth. It is not successful to change the port. The most important thing should be its graphic data, how to read the CFG file data, generate the world, how to transform the output of the screen. I hope to see this is like it. !

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

New Post(0)