⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readolst.cpp

📁 空战游戏flacon源码
💻 CPP
字号:
#include "header.h"
#include "LODutil.h"

struct recordPtr {
	char		name[256], desc[GL_MAX_DESCRIPTION];
	int			id;
	int			maxdof, maxswitch, maxslot, maxanim, maxdvtx;
	GLvertex	*SlotOffset;
	int			totallod;
	float		radius;
	lodPtr		*lod;
	recordPtr	*next;
};

void main (int argc, char *argv[])
{
	puts ("\nRead Object List v1.0 by Erick Jap\n");
	if (argc < 2) {
		puts ("Usage: ReadOLst objectlist");
		exit (1);
	}

	CFileIO myfile;
	if (myfile.openread (argv[1])) {
		recordPtr *ObjectList = 0;	
		recordPtr *curObject;
		GLint i = myfile.read_int ();
		while (1) {
			i = myfile.read_int ();
			if (i == -1) break;
			curObject = (recordPtr *) glAllocateMemory (sizeof(recordPtr));
			if (!curObject) {
				puts ("Fatal Error!! Can not allocate object memory!\n");
				exit (1);
			}
			curObject -> id = i;
			myfile.readdata (curObject -> desc, GL_MAX_DESCRIPTION);
			curObject -> radius = myfile.read_float ();
			curObject -> maxdof = myfile.read_int ();
			curObject -> maxswitch = myfile.read_int ();
			curObject -> maxslot = myfile.read_int ();
			curObject -> maxanim = myfile.read_int ();
			curObject -> maxdvtx = myfile.read_int ();
			curObject -> SlotOffset = 0;
			if (curObject -> maxslot) {
				i = curObject -> maxslot * sizeof (GLvertex);
				curObject -> SlotOffset = (GLvertex *) glAllocateMemory (i);
				if (!curObject -> SlotOffset) {
					puts ("Fatal Error!! Can not allocate slot offset memory!\n");
					exit (1);
				}
				for (i=0; i < curObject -> maxslot; i++) {
					curObject -> SlotOffset[i].x = myfile.read_float ();
					curObject -> SlotOffset[i].y = myfile.read_float ();
					curObject -> SlotOffset[i].z = myfile.read_float ();
				}
			}
			curObject -> totallod = myfile.read_int ();
			i = curObject -> totallod * sizeof (lodPtr);
			curObject -> lod = (lodPtr *) glAllocateMemory (i);
			if (!curObject -> lod) {
				puts ("Fatal Error!! Can not allocate lod memory!\n");
				exit (1);
			}
			lodPtr *lod = curObject -> lod;
			for (i=0; i < curObject -> totallod;i++) {
				lod -> distance = myfile.read_int ();
				lod -> flag = myfile.read_int ();
				myfile.readdata (lod -> name, GL_NAMESIZE);
				lod = lod -> next;
			}
			curObject -> next = 0;

			recordPtr *cur1 = ObjectList;
			recordPtr *cur2 = 0;
			while (cur1) {
				if (curObject -> id < cur1 -> id) {
					curObject -> next = cur1;
					break;
				}
				cur2 = cur1;
				cur1 = cur1 -> next;
			}
			if (cur2) cur2 -> next = curObject;
			else ObjectList = curObject;
		}
		myfile.closefile();

		printf ("Object List:\n\n");
		while (ObjectList) {
			curObject = ObjectList;
			ObjectList = ObjectList -> next;

			printf ("Object ID: %d (%s)\n", curObject -> id, curObject -> desc);
			printf ("Radius: %f\n", curObject -> radius);
			printf ("Total LOD, DOF, Switch, Slot, AnimVar, DynVertex: %d, %d, %d, %d, %d %d\n", 
				curObject -> totallod, curObject -> maxdof, curObject -> maxswitch, 
				curObject -> maxslot, curObject -> maxanim, curObject -> maxdvtx);

			lodPtr *lod = curObject -> lod;
			for (i=0; i < curObject -> totallod;i++) {
				printf ("LOD %d (distance, flag, name): 0x%08X, 0x%08X, %s\n", i, 
					lod -> distance, lod -> flag, lod -> name);
				lod = lod -> next;
			}
			if (curObject -> maxslot) {
				for (i=0; i < curObject -> maxslot; i++) {
					printf ("Slot %d Center (x, y, z) : %f, %f, %f\n", i, 
						curObject -> SlotOffset[i].x, 
						curObject -> SlotOffset[i].y, 
						curObject -> SlotOffset[i].z);
				}
			}

			lod = curObject -> lod;
			while (lod) {
				lodPtr *lod1 = lod;
				lod = lod -> next;
				glReleaseMemory ((char *) lod1);
			}
			glReleaseMemory ((char *) curObject -> SlotOffset);
			glReleaseMemory ((char *) curObject);

			printf ("\n");
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -