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

📄 hottohob.cpp

📁 空战游戏flacon源码
💻 CPP
字号:
#include <stdio.h>
#include <stdlib.h>
#include "..\..\3Dlib\define.h"
#include "..\..\3Dlib\object.h"
#include "..\..\3Dlib\util.h"
#include "..\..\3Dlib\fileio.h"
#include "hotreadr.h"
#include "hobwritr.h"

GLint CompareColor ( const void *arg1, const void *arg2 );

void main (int argc, char *argv[])
{
	if (argc < 2) {
		printf ("\nHOtoHOB v%1.2f by Erick Jap\n", (float) HOB_VERSION/100.f);
		puts ("Usage: HOTtoHOB hotfile [options]");
		puts ("options:");
		puts ("-ohobfile   --> where hobfile is output file");
		puts ("-ttexfile   --> where texfile is the texture list file (Default is texture.lst)");
		puts ("-ccolfile   --> where colfile is the color list file (Default is color.lst)");
		exit (1);
	}

	char infile[80], outfile[80], texfile[80], colfile[80];
	glConcatFileExtension ((GLbyte *) infile, (GLbyte *) argv[1], (GLbyte *) "HOT");
	glConcatFileExtension ((GLbyte *) outfile, (GLbyte *) argv[1], (GLbyte *) "HOB");

	printf ("Converting file %s to %s\n", infile, outfile);

	strcpy (texfile, "texture.lst");
	strcpy (colfile, "color.lst");

	GLint i;
	for (i=2;i < argc;i++) {
		if (argv[i][0] == '-') {
			if (argv[i][1] == 't') {
				strcpy (texfile, &(argv[i][2]));
			}
			else if (argv[i][1] == 'c') {
				strcpy (colfile, &(argv[i][2]));
			}
			else if (argv[i][1] == 'o') {
				glConcatFileExtension ((GLbyte *) outfile, (GLbyte *) &(argv[i][2]), (GLbyte *) "HOB");
			}

		}
	}

	glSetupTextureList (NULL, texfile);

	CFileIO col;
	if (!col.openread (colfile)) {
		printf ("Can not open %s\n", colfile);
		exit (1);
	}
	i = col.read_int ();
	ColorListRecord *coltable = (ColorListRecord *) glAllocateMemory (i * sizeof (ColorListRecord));
	if (!coltable) {
		printf ("Can not allocate color table\n");
		col.closefile();
		exit (1);
	}
	GLint j;
	for (j=0; j < i; j++) {
		coltable[j].colorindex = j;
		coltable[j].color = col.read_int();
	}
	qsort ((void *) coltable, (size_t) i, sizeof(ColorListRecord), CompareColor);
	col.closefile();

	CHOTReader hot;
	GLObjectData *objData = hot.readHOT (infile, coltable, i, 0);
	if (!objData) {
		printf ("Can not create HOT object\n");
		exit (1);
	}

	CHOBWriter hob;
	if (hob.CreateHOBFile ((GLbyte *) outfile, objData)) {
		printf ("Can not create HOB file\n");
		exit (1);
	}

	exit (0);
}

GLint CompareColor ( const void *arg1, const void *arg2 )
{
	ColorListRecord *rec1 = (ColorListRecord *) arg1;
	ColorListRecord *rec2 = (ColorListRecord *) arg2;
	if (rec1 -> color < rec2 -> color) return -1;
	if (rec1 -> color > rec2 -> color) return 1;
	return 0;
}

⌨️ 快捷键说明

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