mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Remove trailing whitespace
This commit is contained in:
@@ -106,14 +106,14 @@ IF(MSVC)
|
||||
SET(glmodelviewer_sources
|
||||
GLModelViewer.cpp
|
||||
)
|
||||
|
||||
|
||||
SET(glmodelviewer_headers
|
||||
GLModelViewer.h
|
||||
)
|
||||
|
||||
|
||||
ADD_EXECUTABLE(glmodelviewer WIN32 ${glmodelviewer_sources} ${glmodelviewer_headers})
|
||||
TARGET_LINK_LIBRARIES(glmodelviewer azone_common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} "opengl32.lib" "GLU32.lib" "Ws2_32.lib")
|
||||
SET_TARGET_PROPERTIES(glmodelviewer PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ../../Bin)
|
||||
ENDIF(MSVC)
|
||||
|
||||
+112
-112
@@ -30,7 +30,7 @@ typedef struct _vertex{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
|
||||
}VERTEX;
|
||||
|
||||
void DrawEQModel(FileLoader *fileloader, int modnum);
|
||||
@@ -43,10 +43,10 @@ HGLRC hRC=NULL;
|
||||
HWND hWnd=NULL;
|
||||
HINSTANCE hInstance;
|
||||
|
||||
bool keys[256];
|
||||
bool keys[256];
|
||||
char ch;
|
||||
bool active=true;
|
||||
GLuint base;
|
||||
GLuint base;
|
||||
|
||||
int modelnum = 1; // The Number of the model we are currently displaying.
|
||||
float angle = 0; // used to rotate the model. Updated by a timer
|
||||
@@ -62,72 +62,72 @@ GLvoid BuildFont(GLvoid)
|
||||
|
||||
font = CreateFont(-24, 0, 0, 0, FW_BOLD, false, false, false, ANSI_CHARSET,
|
||||
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
|
||||
FF_DONTCARE|DEFAULT_PITCH, "Courier New");
|
||||
FF_DONTCARE|DEFAULT_PITCH, "Courier New");
|
||||
|
||||
oldfont = (HFONT)SelectObject(hDC, font);
|
||||
wglUseFontBitmaps(hDC, 32, 96, base);
|
||||
SelectObject(hDC, oldfont);
|
||||
DeleteObject(font);
|
||||
oldfont = (HFONT)SelectObject(hDC, font);
|
||||
wglUseFontBitmaps(hDC, 32, 96, base);
|
||||
SelectObject(hDC, oldfont);
|
||||
DeleteObject(font);
|
||||
}
|
||||
|
||||
GLvoid KillFont(GLvoid)
|
||||
GLvoid KillFont(GLvoid)
|
||||
{
|
||||
glDeleteLists(base, 96);
|
||||
glDeleteLists(base, 96);
|
||||
}
|
||||
|
||||
GLvoid glPrint(const char *fmt, ...)
|
||||
{
|
||||
char text[256];
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
|
||||
if (fmt == NULL) return;
|
||||
if (fmt == NULL) return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsprintf(text, fmt, ap);
|
||||
va_end(ap);
|
||||
va_start(ap, fmt);
|
||||
vsprintf(text, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
glPushAttrib(GL_LIST_BIT);
|
||||
glListBase(base - 32);
|
||||
glPushAttrib(GL_LIST_BIT);
|
||||
glListBase(base - 32);
|
||||
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
|
||||
glPopAttrib();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
|
||||
{
|
||||
if (height==0)height=1;
|
||||
if (height==0)height=1;
|
||||
|
||||
glViewport(0,0,width,height);
|
||||
glViewport(0,0,width,height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glLoadIdentity();
|
||||
gluPerspective(60.0f,(GLfloat)width/(GLfloat)height,0.1f,12000.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
int InitGL(GLvoid)
|
||||
int InitGL(GLvoid)
|
||||
{
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
glClearDepth(1.0f);
|
||||
glClearDepth(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
BuildFont();
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int DrawGLScene(char *ZoneFileName)
|
||||
int DrawGLScene(char *ZoneFileName)
|
||||
{
|
||||
char textBuffer[100];
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
glLoadIdentity();
|
||||
|
||||
if(mfileloader->model_data.models[modelnum])
|
||||
DrawEQModel(mfileloader, modelnum);
|
||||
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f,0.0f,-1.2f);
|
||||
glTranslatef(0.0f,0.0f,-1.2f);
|
||||
glColor3f(100.0f,0.0f,0.0f);
|
||||
glRasterPos2f(-1.15f,0.56f);
|
||||
|
||||
@@ -139,17 +139,17 @@ int DrawGLScene(char *ZoneFileName)
|
||||
else
|
||||
sprintf(textBuffer," %s: Model Number %4d. Not Viewable (probably zone mesh).", ZoneFileName, modelnum);
|
||||
|
||||
glPrint(textBuffer);
|
||||
glPrint(textBuffer);
|
||||
sprintf(textBuffer," Use the + and - keys to cycle through models.");
|
||||
glRasterPos2f(-1.15f,0.50f);
|
||||
glPrint(textBuffer);
|
||||
glPrint(textBuffer);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GLvoid KillGLWindow(GLvoid) {
|
||||
if (hRC) {
|
||||
if (hRC) {
|
||||
if (!wglMakeCurrent(NULL,NULL)) {
|
||||
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
@@ -157,107 +157,107 @@ GLvoid KillGLWindow(GLvoid) {
|
||||
if (!wglDeleteContext(hRC)) {
|
||||
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
hRC=NULL;
|
||||
hRC=NULL;
|
||||
}
|
||||
|
||||
if (hDC && !ReleaseDC(hWnd,hDC)) {
|
||||
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
hDC=NULL;
|
||||
hDC=NULL;
|
||||
}
|
||||
|
||||
if (hWnd && !DestroyWindow(hWnd)) {
|
||||
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
hWnd=NULL;
|
||||
hWnd=NULL;
|
||||
}
|
||||
|
||||
if (!UnregisterClass("OpenGL",hInstance)) {
|
||||
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||
hInstance=NULL;
|
||||
hInstance=NULL;
|
||||
}
|
||||
KillFont();
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CreateGLWindow(char* title, int width, int height, int bits) {
|
||||
GLuint PixelFormat;
|
||||
WNDCLASS wc;
|
||||
WNDCLASS wc;
|
||||
DWORD dwExStyle;
|
||||
DWORD dwStyle;
|
||||
RECT WindowRect;
|
||||
WindowRect.left=(long)0;
|
||||
WindowRect.right=(long)width;
|
||||
WindowRect.top=(long)0;
|
||||
WindowRect.bottom=(long)height;
|
||||
WindowRect.right=(long)width;
|
||||
WindowRect.top=(long)0;
|
||||
WindowRect.bottom=(long)height;
|
||||
|
||||
hInstance = GetModuleHandle(NULL);
|
||||
hInstance = GetModuleHandle(NULL);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wc.lpfnWndProc = (WNDPROC) WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.lpfnWndProc = (WNDPROC) WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "OpenGL";
|
||||
|
||||
if (!RegisterClass(&wc)) {
|
||||
MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
||||
dwStyle=WS_OVERLAPPEDWINDOW;
|
||||
dwStyle=WS_OVERLAPPEDWINDOW;
|
||||
|
||||
AdjustWindowRectEx(&WindowRect, dwStyle, false, dwExStyle);
|
||||
|
||||
if (!(hWnd=CreateWindowEx(dwExStyle, "OpenGL", title, dwStyle|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
|
||||
0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top,
|
||||
NULL, NULL, hInstance, NULL))) {
|
||||
KillGLWindow();
|
||||
KillGLWindow();
|
||||
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
static PIXELFORMATDESCRIPTOR pfd= {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA, bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE,
|
||||
0, 0, 0, 0
|
||||
0, 0, 0, 0
|
||||
};
|
||||
|
||||
|
||||
if (!(hDC=GetDC(hWnd))) {
|
||||
KillGLWindow();
|
||||
KillGLWindow();
|
||||
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) {
|
||||
KillGLWindow();
|
||||
KillGLWindow();
|
||||
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!SetPixelFormat(hDC,PixelFormat,&pfd)) {
|
||||
KillGLWindow();
|
||||
KillGLWindow();
|
||||
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(hRC=wglCreateContext(hDC))) {
|
||||
KillGLWindow();
|
||||
KillGLWindow();
|
||||
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!wglMakeCurrent(hDC,hRC)) {
|
||||
KillGLWindow();
|
||||
KillGLWindow();
|
||||
MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowWindow(hWnd,SW_SHOW);
|
||||
SetForegroundWindow(hWnd);
|
||||
SetFocus(hWnd);
|
||||
SetForegroundWindow(hWnd);
|
||||
SetFocus(hWnd);
|
||||
ReSizeGLScene(width, height);
|
||||
|
||||
if (!InitGL()) {
|
||||
@@ -268,17 +268,17 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits) {
|
||||
|
||||
SetTimer(hWnd, 1, 50, (TIMERPROC) NULL);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_ACTIVATE:
|
||||
if (!HIWORD(wParam)) active=true;
|
||||
case WM_ACTIVATE:
|
||||
if (!HIWORD(wParam)) active=true;
|
||||
else
|
||||
active=false;
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
case WM_SYSCOMMAND:
|
||||
switch (wParam) {
|
||||
case SC_SCREENSAVE:
|
||||
@@ -288,19 +288,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
return 0;
|
||||
case WM_KEYDOWN:
|
||||
keys[wParam] = true;
|
||||
return 0;
|
||||
return 0;
|
||||
case WM_CHAR:
|
||||
ch = wParam;
|
||||
return 0;
|
||||
case WM_KEYUP:
|
||||
keys[wParam] = false;
|
||||
return 0;
|
||||
case WM_SIZE:
|
||||
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));
|
||||
return 0;
|
||||
case WM_KEYUP:
|
||||
keys[wParam] = false;
|
||||
return 0;
|
||||
case WM_SIZE:
|
||||
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));
|
||||
return 0;
|
||||
case WM_TIMER:
|
||||
angle = angle + 1;
|
||||
if(angle>359) angle = 0;
|
||||
@@ -327,7 +327,7 @@ void ScaleVertex(VERTEX &v, float XScale, float YScale, float ZScale) {
|
||||
|
||||
|
||||
void DrawEQModel(FileLoader *fileloader, int modnum) {
|
||||
|
||||
|
||||
Polygon *poly;
|
||||
Vertex *verts[3];
|
||||
VERTEX v1, v2, v3;
|
||||
@@ -363,16 +363,16 @@ void DrawEQModel(FileLoader *fileloader, int modnum) {
|
||||
if(maxz-minz>maxDimension) maxDimension = maxz-minz;
|
||||
|
||||
// Hack for very small models (e.g. spoons)
|
||||
if(maxDimension>1)
|
||||
glTranslatef(-1.5f,0.0f,-(maxDimension*2));
|
||||
if(maxDimension>1)
|
||||
glTranslatef(-1.5f,0.0f,-(maxDimension*2));
|
||||
else
|
||||
glTranslatef(-1.5f,0.0f,-10);
|
||||
glTranslatef(-1.5f,0.0f,-10);
|
||||
|
||||
// angle is updated by a timer every 50ms.
|
||||
glRotatef(angle, 1, 0, 0);
|
||||
glRotatef(angle, 0, 1, 0);
|
||||
glRotatef(angle, 0, 0, 1);
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
for(int i = 0; i < model->poly_count; ++i) {
|
||||
@@ -398,23 +398,23 @@ void DrawEQModel(FileLoader *fileloader, int modnum) {
|
||||
ScaleVertex(v2, 10, 10, 10);
|
||||
ScaleVertex(v3, 10, 10, 10);
|
||||
}
|
||||
|
||||
|
||||
// Assign a kind of random colour to each polygon
|
||||
|
||||
//glColor3b((i%50)+50,(i*5)%200,(i*10)%200);
|
||||
float col = (float)(100 + ((i*10) % 150)) /250 * 1.0f;
|
||||
glColor3f(col, col, col);
|
||||
|
||||
|
||||
glVertex3f(v1.x, v1.z, v1.y);
|
||||
glVertex3f(v2.x, v2.z, v2.y);
|
||||
glVertex3f(v3.x, v3.z, v3.y);
|
||||
|
||||
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
bool ProcessZoneFile(const char *shortname) {
|
||||
|
||||
|
||||
char bufs[96];
|
||||
Archive *archive;
|
||||
|
||||
@@ -427,7 +427,7 @@ bool ProcessZoneFile(const char *shortname) {
|
||||
|
||||
archive = new PFSLoader();
|
||||
fff = fopen(bufs, "rb");
|
||||
if(fff != NULL)
|
||||
if(fff != NULL)
|
||||
FileType = S3D;
|
||||
else {
|
||||
sprintf(bufs, "%s.eqg", shortname);
|
||||
@@ -443,15 +443,15 @@ bool ProcessZoneFile(const char *shortname) {
|
||||
|
||||
if(archive->Open(fff) == 0) {
|
||||
MessageBox(NULL,"Unable to open container file","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
switch(FileType) {
|
||||
case S3D:
|
||||
case S3D:
|
||||
mfileloader = new WLDLoader();
|
||||
if(mfileloader->Open(NULL, (char *) shortname, archive) == 0) {
|
||||
|
||||
|
||||
MessageBox(NULL,"Error reading WLD from container file","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return(false);
|
||||
}
|
||||
@@ -485,11 +485,11 @@ bool ProcessZoneFile(const char *shortname) {
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
MSG msg;
|
||||
BOOL done=false;
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
|
||||
for(int i=0;i<256;i++)
|
||||
for(int i=0;i<256;i++)
|
||||
keys[i] = false;
|
||||
|
||||
|
||||
|
||||
char* buf = (char *) new char[strlen(lpCmdLine) + 1] ;
|
||||
char *pTmp = buf;
|
||||
@@ -501,48 +501,48 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
}
|
||||
|
||||
strcpy(buf,lpCmdLine);
|
||||
|
||||
|
||||
if(!ProcessZoneFile(buf)) return 0;
|
||||
|
||||
|
||||
if (!CreateGLWindow("EQ Model Viewer",1280,768,16))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
while(!done) {
|
||||
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
|
||||
if (msg.message==WM_QUIT)
|
||||
done=true;
|
||||
if (msg.message==WM_QUIT)
|
||||
done=true;
|
||||
else {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((active && !DrawGLScene(buf)) || keys[VK_ESCAPE])
|
||||
done=true;
|
||||
if ((active && !DrawGLScene(buf)) || keys[VK_ESCAPE])
|
||||
done=true;
|
||||
else
|
||||
SwapBuffers(hDC);
|
||||
SwapBuffers(hDC);
|
||||
|
||||
// Use + and - to cycle through the models
|
||||
|
||||
if (toupper(ch)=='+') {
|
||||
if(modelnum+1 < mfileloader->model_data.model_count)
|
||||
if (toupper(ch)=='+') {
|
||||
if(modelnum+1 < mfileloader->model_data.model_count)
|
||||
modelnum++;
|
||||
else
|
||||
modelnum=0;
|
||||
angle = 0;
|
||||
}
|
||||
if (toupper(ch)=='-') {
|
||||
if (toupper(ch)=='-') {
|
||||
if(modelnum>0)
|
||||
modelnum--;
|
||||
else
|
||||
modelnum = mfileloader->model_data.model_count - 1;
|
||||
|
||||
angle = 0;
|
||||
angle = 0;
|
||||
}
|
||||
ch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
KillGLWindow();
|
||||
return (msg.wParam);
|
||||
return (msg.wParam);
|
||||
}
|
||||
|
||||
+24
-24
@@ -10,22 +10,22 @@
|
||||
|
||||
Father Nitwit's Zone to map conversion program.
|
||||
Copyright (C) 2004 Father Nitwit (eqemu@8ass.com)
|
||||
|
||||
|
||||
This thing uses code from freaku, so whatever license that comes under
|
||||
is relavent, if you care.
|
||||
|
||||
|
||||
the rest of it is GPL, even though I hate the GPL.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -76,7 +76,7 @@ long BSPCountNodes(BSP_Node *tree, long node_number);
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
long DefaultRegionType=RegionTypeWater;
|
||||
|
||||
|
||||
if((argc < 2) ||
|
||||
(argc > 3) ||
|
||||
#ifndef WIN32
|
||||
@@ -90,9 +90,9 @@ int main(int argc, char *argv[]) {
|
||||
printf("\nIf -dl is omitted, untagged special regions will be marked as water\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
char bufm[250];
|
||||
|
||||
|
||||
if(argc==3)
|
||||
DefaultRegionType=RegionTypeLava;
|
||||
sprintf(bufm, "%s.wtr", argv[argc-1]);
|
||||
@@ -110,15 +110,15 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
|
||||
char bufs[96];
|
||||
Archive *archive;
|
||||
WLDLoader *fileloader;
|
||||
long WaterOrLavaCount = 0;
|
||||
|
||||
long WaterOrLavaCount = 0;
|
||||
|
||||
//TODO: clean up a LOT of memory that the freaku code does not
|
||||
|
||||
|
||||
|
||||
sprintf(bufs, "%s.s3d", shortname);
|
||||
|
||||
archive = new PFSLoader();
|
||||
|
||||
|
||||
FILE *s3df = fopen(bufs, "rb");
|
||||
if(s3df == nullptr) {
|
||||
// One day we may try EQG, but not today.
|
||||
@@ -131,8 +131,8 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
|
||||
}
|
||||
printf("Loading %s...\n", bufs);
|
||||
|
||||
fileloader = new WLDLoader();
|
||||
|
||||
fileloader = new WLDLoader();
|
||||
|
||||
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
|
||||
printf("Error reading WLD from %s\n", bufs);
|
||||
return(false);
|
||||
@@ -152,7 +152,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
|
||||
case RegionTypeUnsupported: { printf("Unsupported\n"); break; }
|
||||
case RegionTypeUntagged: {
|
||||
printf("Untagged. We will set it to ");
|
||||
if(DefaultRegionType==RegionTypeWater) {
|
||||
if(DefaultRegionType==RegionTypeWater) {
|
||||
printf("Water\n");
|
||||
} else printf("Lava\n");
|
||||
data29->region_type = DefaultRegionType;
|
||||
@@ -172,7 +172,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(tree==nullptr) {
|
||||
printf("No BSP Tree. Bailing out\n");
|
||||
return(false);
|
||||
@@ -184,12 +184,12 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
|
||||
|
||||
// Now we mark each leaf in the BSP tree that is in a 'special area' with what type the area is
|
||||
// Water, Lava, Zoneline etc
|
||||
|
||||
|
||||
for(int i=0; i<fileloader->fragcount; i++) {
|
||||
if(fileloader->frags[i]->type == 0x29) {
|
||||
data29 = (struct_Data29 *) fileloader->frags[i]->frag;
|
||||
for(long j=0; j<data29->region_count; j++) {
|
||||
BSPMarkRegion(tree, 1,data29->region_array[j]+1, data29->region_type);
|
||||
BSPMarkRegion(tree, 1,data29->region_array[j]+1, data29->region_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ long BSPCountNodes(BSP_Node *tree, long node_number) {
|
||||
return(NodesInRightBranch + NodesInLeftBranch + 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
long BSPFindRegion(BSP_Node *tree, long node_number, long region) {
|
||||
//printf("Find Region %ld in node %ld\n", region, node_number);
|
||||
@@ -281,7 +281,7 @@ long BSPFindRegion(BSP_Node *tree, long node_number, long region) {
|
||||
if(tree[node_number-1].region==region) return node_number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
long retnode ;
|
||||
if(tree[node_number-1].left!=0) {
|
||||
retnode = BSPFindRegion(tree, tree[node_number-1].left, region);
|
||||
@@ -303,15 +303,15 @@ long BSPFindNode(BSP_Node *tree, long node_number, float x, float y, float z) {
|
||||
|
||||
printf("BSP Find Node, currently in Node %ld\n", node_number);
|
||||
// Are we at a leaf
|
||||
|
||||
|
||||
if((tree[node_number-1].left==0)&&
|
||||
(tree[node_number-1].right==0)) {
|
||||
return tree[node_number-1].region;
|
||||
}
|
||||
|
||||
|
||||
// No, so determine which side of the split plane we are on
|
||||
//
|
||||
|
||||
|
||||
distance = (x * tree[node_number-1].normal[0]) +
|
||||
(y * tree[node_number-1].normal[1]) +
|
||||
(z * tree[node_number-1].normal[2]) +
|
||||
@@ -341,7 +341,7 @@ long BSPFindNode(BSP_Node *tree, long node_number, float x, float y, float z) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
long BSPMarkRegion(BSP_Node *tree, long node_number, long region, int region_type) {
|
||||
//printf("Find Region %ld in node %ld\n", region, node_number);
|
||||
if(node_number<1) {
|
||||
@@ -369,7 +369,7 @@ long BSPMarkRegion(BSP_Node *tree, long node_number, long region, int region_typ
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+24
-24
@@ -38,7 +38,7 @@ using namespace std;
|
||||
unsigned shorts are adequate because, worst case
|
||||
even in a zone that is 6000x6000 with a small node
|
||||
size of 30x30, there are only 40000 nodes.
|
||||
|
||||
|
||||
quadrent definitions:
|
||||
quad 1 (nodes[0]):
|
||||
x>=0, y>=0
|
||||
@@ -48,7 +48,7 @@ using namespace std;
|
||||
x<0, y<0
|
||||
quad 4 (nodes[3]):
|
||||
x>=0, y<0
|
||||
|
||||
|
||||
*/
|
||||
#define MAX_POLY_VTX 24 //arbitrary, im too lazy to figure it out
|
||||
//cut a triangle at most 6 times....
|
||||
@@ -65,12 +65,12 @@ public:
|
||||
GPoint();
|
||||
GPoint(VERTEX &v);
|
||||
GPoint(float x, float y, float z);
|
||||
|
||||
|
||||
inline void operator()(float nx, float ny, float nz) { x = nx; y = ny; z = nz; }
|
||||
|
||||
|
||||
GPoint cross(const GPoint &them) const;
|
||||
float dot3(const GPoint &them) const;
|
||||
|
||||
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
@@ -83,13 +83,13 @@ public:
|
||||
GVector();
|
||||
GVector(const GPoint &them);
|
||||
GVector(float x, float y, float z, float w = 1.0f);
|
||||
|
||||
|
||||
inline void operator()(float nx, float ny, float nz, float nw) { x = nx; y = ny; z = nz; W = nw; }
|
||||
float dot4(const GVector &them) const;
|
||||
float dot4(const GPoint &them) const;
|
||||
void normalize();
|
||||
float length();
|
||||
|
||||
|
||||
float W;
|
||||
};
|
||||
|
||||
@@ -104,7 +104,7 @@ class QTBuilder {
|
||||
public:
|
||||
QTBuilder();
|
||||
~QTBuilder();
|
||||
|
||||
|
||||
bool build(const char *shortname);
|
||||
bool build_eqg(const char *shortname);
|
||||
void AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool ListPlaceable=false);
|
||||
@@ -113,28 +113,28 @@ public:
|
||||
void ScaleVertex(VERTEX &v, float XScale, float YScale, float ZScale);
|
||||
void TranslateVertex(VERTEX &v, float XOffset, float YOffset, float ZOffset);
|
||||
bool writeMap(const char *file);
|
||||
|
||||
|
||||
bool FaceInNode(const QTNode *q, const FACE *f);
|
||||
protected:
|
||||
|
||||
|
||||
void AddFace(VERTEX &v1, VERTEX &v2, VERTEX &v3);
|
||||
|
||||
|
||||
int ClipPolygon(POLYGON *poly, GVector *plane);
|
||||
|
||||
|
||||
//dynamic during load
|
||||
// vector<VERTEX> _VertexList;
|
||||
vector<FACE> _FaceList;
|
||||
|
||||
|
||||
//static once loaded
|
||||
// unsigned long vertexCount;
|
||||
unsigned long faceCount;
|
||||
// VERTEX * vertexBlock;
|
||||
FACE * faceBlock;
|
||||
|
||||
|
||||
VERTEX tempvtx[MAX_POLY_VTX];
|
||||
|
||||
|
||||
QTNode *_root;
|
||||
|
||||
|
||||
static void NormalizeN(FACE *p);
|
||||
|
||||
#ifdef COUNT_MACTHES
|
||||
@@ -151,28 +151,28 @@ class QTNode {
|
||||
public:
|
||||
QTNode(QTBuilder *builder, float Tminx, float Tmaxx, float Tminy, float Tmaxy);
|
||||
~QTNode();
|
||||
|
||||
|
||||
void clearNodes();
|
||||
|
||||
|
||||
void doSplit();
|
||||
void divideYourself(int depth);
|
||||
|
||||
|
||||
void buildVertexes();
|
||||
|
||||
// bool writeFile(FILE *out);
|
||||
|
||||
|
||||
unsigned long countNodes() const;
|
||||
unsigned long countFacelists() const;
|
||||
|
||||
|
||||
void fillBlocks(nodeHeader *heads, unsigned long *flist, unsigned long &hindex, unsigned long &findex);
|
||||
|
||||
|
||||
float minx;
|
||||
float miny;
|
||||
float maxx;
|
||||
float maxy;
|
||||
unsigned long nfaces;
|
||||
vector<FaceRecord> faces;
|
||||
|
||||
|
||||
/*
|
||||
quadrent definitions:
|
||||
quad 1 (node1):
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
QTNode *node4;
|
||||
GPoint v[8];
|
||||
bool final;
|
||||
|
||||
|
||||
protected:
|
||||
QTBuilder *builder;
|
||||
};
|
||||
|
||||
+39
-39
@@ -98,14 +98,14 @@ string GetToken(uchar *&Buffer, int &Position)
|
||||
++Position;
|
||||
}
|
||||
++Position;
|
||||
//printf("Returning %s\n", Token.c_str());
|
||||
//printf("Returning %s\n", Token.c_str());
|
||||
return Token;
|
||||
}
|
||||
|
||||
int AddModelName(Content_3D *C3D, string ModelName)
|
||||
{
|
||||
vector<string>::iterator Iterator;
|
||||
|
||||
|
||||
for(unsigned int i = 0; i < C3D->ModelNames.size(); ++i)
|
||||
{
|
||||
#ifndef WIN32
|
||||
@@ -116,8 +116,8 @@ int AddModelName(Content_3D *C3D, string ModelName)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
C3D->ModelNames.push_back(ModelName);
|
||||
|
||||
return C3D->ModelNames.size() - 1;
|
||||
@@ -171,7 +171,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
if(filename != zone_name)
|
||||
delete[] filename;
|
||||
|
||||
|
||||
|
||||
buf_start = buffer;
|
||||
|
||||
//TODO: Find out what these three unknowns are
|
||||
@@ -341,10 +341,10 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
|
||||
this->model_data.zone_model = new Zone_Model;
|
||||
zm = this->model_data.zone_model;
|
||||
|
||||
|
||||
zm->vert_count = QuadCount * TileCount * 4;
|
||||
zm->poly_count = QuadCount * 2 * TileCount;
|
||||
|
||||
|
||||
zm->verts = new Vertex *[zm->vert_count];
|
||||
zm->polys = new Polygon *[zm->poly_count];
|
||||
|
||||
@@ -360,7 +360,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
|
||||
for(int TileNumber = 0; TileNumber < TileCount; ++TileNumber)
|
||||
{
|
||||
|
||||
|
||||
int TileLNG = VARSTRUCT_DECODE_TYPE(uint32, buffer);
|
||||
int TileLAT = VARSTRUCT_DECODE_TYPE(uint32, buffer);
|
||||
int TileUNK = VARSTRUCT_DECODE_TYPE(uint32, buffer);
|
||||
@@ -449,7 +449,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
int LayerCount = VARSTRUCT_DECODE_TYPE(uint32, buffer);
|
||||
|
||||
VARSTRUCT_DECODE_STRING(s, buffer);
|
||||
|
||||
|
||||
int OverlayCount = 0;
|
||||
|
||||
for(int Layer = 1; Layer < LayerCount; ++Layer)
|
||||
@@ -462,10 +462,10 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
{
|
||||
uint8 Byte = VARSTRUCT_DECODE_TYPE(uint8, buffer);
|
||||
}
|
||||
|
||||
|
||||
++OverlayCount;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int Count1 = VARSTRUCT_DECODE_TYPE(uint32, buffer);
|
||||
#ifdef DEBUGDAT
|
||||
@@ -517,7 +517,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
printf("Model: %s LOC: %8.3f, %8.3f, %8.3f, ROT: %8.3f, %8.3f, %8.3f\n", ModelName, x, y, z, RotX, RotY, RotZ);
|
||||
#endif
|
||||
ObjectGroupEntry NewObjectGroup;
|
||||
|
||||
|
||||
NewObjectGroup.FromTOG = false;
|
||||
|
||||
NewObjectGroup.y = y;
|
||||
@@ -534,18 +534,18 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
// of another tile, which means based on the data for the tile we are processing, we should be unable to
|
||||
// calculate the Z value for that object.
|
||||
//
|
||||
// By hand editing an .EQG, it was discovered that what the client appears to do is calculate the Z value
|
||||
// By hand editing an .EQG, it was discovered that what the client appears to do is calculate the Z value
|
||||
// for these objects by adjusting the x/y offsets by +/- (QuadsPerTile * UnitsPerVert) until the offsets
|
||||
// are within this tiles boundaries and using the corresponding height values.
|
||||
//
|
||||
// For example, if a model has an offset of -157.5, -157.5 and QPT * UPV = 160, then the height value used
|
||||
// For example, if a model has an offset of -157.5, -157.5 and QPT * UPV = 160, then the height value used
|
||||
// would be the height at +2.5, +2.5 in this tile.
|
||||
//
|
||||
// This doesn't make a great deal of sense, but it is how the EQ graphics engine appears to do things.
|
||||
//
|
||||
// These 'Adjusted' x/y offsets are used only for determing the ground Z for the object. The actual placement
|
||||
// of the object relative to the terrain uses the unadjusted offsets.
|
||||
//
|
||||
//
|
||||
// For the record, as of SoF, this applies to the following zones and objects:
|
||||
//
|
||||
// arcstone: Model translations adjusted from -14.000, 219.000 to 146.000, 59.000
|
||||
@@ -737,7 +737,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
|
||||
float ZAdjust = VARSTRUCT_DECODE_TYPE(float, buffer);
|
||||
#ifdef DEBUGDAT
|
||||
printf("ZAdjust %8.3f\n", ZAdjust);
|
||||
printf("ZAdjust %8.3f\n", ZAdjust);
|
||||
#endif
|
||||
char TogFileName[255];
|
||||
|
||||
@@ -764,7 +764,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
NewObjectGroup.TileY = TileXStart;
|
||||
|
||||
NewObjectGroup.TileZ = 0;
|
||||
|
||||
|
||||
NewObjectGroup.RotX = RotX;
|
||||
NewObjectGroup.RotY = RotY;
|
||||
NewObjectGroup.RotZ = RotZ;
|
||||
@@ -821,7 +821,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
NewObjectGroup.SubObjects.push_back(model_data.PlaceableList.size()-1);
|
||||
}
|
||||
if(Token == "*END_OBJECTGROUP")
|
||||
{
|
||||
{
|
||||
#ifdef DEBUGDAT
|
||||
printf("Pushing back new ObjectGroup\n");
|
||||
printf(" Position : %8.3f, %8.3f, %8.3f\n", NewObjectGroup.x, NewObjectGroup.y, NewObjectGroup.z);
|
||||
@@ -867,7 +867,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
float QuadVertex2X = QuadVertex1X + (QuadsPerTile * UnitsPerVertX);
|
||||
float QuadVertex2Y = QuadVertex1Y;
|
||||
float QuadVertex2Z = QuadVertex1Z;
|
||||
|
||||
|
||||
float QuadVertex3X = QuadVertex2X;
|
||||
float QuadVertex3Y = QuadVertex1Y + (QuadsPerTile * UnitsPerVertY);
|
||||
float QuadVertex3Z = QuadVertex1Z;
|
||||
@@ -875,7 +875,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
float QuadVertex4X = QuadVertex1X;
|
||||
float QuadVertex4Y = QuadVertex3Y;
|
||||
float QuadVertex4Z = QuadVertex1Z;
|
||||
|
||||
|
||||
|
||||
++VertexNumber;
|
||||
|
||||
@@ -903,7 +903,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
zm->polys[PolyNumber]->v1 = VertexNumber;
|
||||
zm->polys[PolyNumber]->v2 = VertexNumber - 3;
|
||||
zm->polys[PolyNumber]->v3 = VertexNumber - 2;
|
||||
zm->polys[PolyNumber]->tex = -1;
|
||||
zm->polys[PolyNumber]->tex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -915,7 +915,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
{
|
||||
if((Quad % QuadsPerTile) == 0)
|
||||
++RowNumber;
|
||||
|
||||
|
||||
// Other common values for this Byte are 0x80, 0x82. Setting them all to zero has no obvious visual
|
||||
// effect.
|
||||
if(Bytes[Quad] & 0x01) // Indicates Quad should not be included because an object will overlay it.
|
||||
@@ -924,47 +924,47 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
float QuadVertex1X = TileXStart + (RowNumber * UnitsPerVertX);
|
||||
float QuadVertex1Y = TileYStart + (Quad % QuadsPerTile) * UnitsPerVertY;
|
||||
float QuadVertex1Z = Floats[Quad + RowNumber];
|
||||
|
||||
|
||||
float QuadVertex2X = QuadVertex1X + UnitsPerVertX;
|
||||
float QuadVertex2Y = QuadVertex1Y;
|
||||
float QuadVertex2Z = Floats[Quad + RowNumber + QuadsPerTile + 1];
|
||||
|
||||
|
||||
float QuadVertex3X = QuadVertex1X + UnitsPerVertX;
|
||||
float QuadVertex3Y = QuadVertex1Y + UnitsPerVertY;
|
||||
float QuadVertex3Z = Floats[Quad + RowNumber + QuadsPerTile + 2];
|
||||
|
||||
|
||||
float QuadVertex4X = QuadVertex1X;
|
||||
float QuadVertex4Y = QuadVertex1Y + UnitsPerVertY;
|
||||
float QuadVertex4Z = Floats[Quad + RowNumber + 1];
|
||||
|
||||
|
||||
++VertexNumber;
|
||||
|
||||
|
||||
zm->verts[VertexNumber++] = new Vertex(QuadVertex1Y, QuadVertex1X, QuadVertex1Z);
|
||||
|
||||
|
||||
zm->verts[VertexNumber++] = new Vertex(QuadVertex2Y, QuadVertex2X, QuadVertex2Z);
|
||||
|
||||
|
||||
zm->verts[VertexNumber++] = new Vertex(QuadVertex3Y, QuadVertex3X, QuadVertex3Z);
|
||||
|
||||
|
||||
zm->verts[VertexNumber] = new Vertex(QuadVertex4Y, QuadVertex4X, QuadVertex4Z);
|
||||
|
||||
|
||||
PolyNumber++;
|
||||
|
||||
|
||||
zm->polys[PolyNumber] = new Polygon;
|
||||
|
||||
|
||||
zm->polys[PolyNumber]->v1 = VertexNumber;
|
||||
zm->polys[PolyNumber]->v2 = VertexNumber - 2;
|
||||
zm->polys[PolyNumber]->v3 = VertexNumber - 1;
|
||||
zm->polys[PolyNumber]->tex = -1;
|
||||
|
||||
|
||||
PolyNumber++;
|
||||
|
||||
|
||||
zm->polys[PolyNumber] = new Polygon;
|
||||
|
||||
|
||||
zm->polys[PolyNumber]->v1 = VertexNumber;
|
||||
zm->polys[PolyNumber]->v2 = VertexNumber - 3;
|
||||
zm->polys[PolyNumber]->v3 = VertexNumber - 2;
|
||||
zm->polys[PolyNumber]->tex = -1;
|
||||
|
||||
zm->polys[PolyNumber]->tex = -1;
|
||||
|
||||
}
|
||||
}
|
||||
zm->vert_count = VertexNumber + 1;
|
||||
@@ -995,7 +995,7 @@ int DATLoader::Close() {
|
||||
|
||||
for(i = 0; i < zm->poly_count; ++i)
|
||||
delete zm->polys[i];
|
||||
|
||||
|
||||
delete[] zm->verts;
|
||||
|
||||
delete[] zm->polys;
|
||||
|
||||
+13
-13
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
|
||||
List Placeable Objects in an S3D or EQG.
|
||||
List Placeable Objects in an S3D or EQG.
|
||||
By Derision, based on OpenEQ File Loaders by Daeken et al.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -48,29 +48,29 @@ enum EQFileType { S3D, EQG, UNKNOWN };
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
printf("LISTOBJ: List Placeable Objects in .S3D or .EQG zone files.\n");
|
||||
|
||||
|
||||
if(argc != 2) {
|
||||
printf("Usage: %s (zone short name)\n", argv[0]);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
return(ProcessZoneFile(argv[1]));
|
||||
}
|
||||
|
||||
bool ProcessZoneFile(const char *shortname) {
|
||||
|
||||
|
||||
char bufs[96];
|
||||
Archive *archive;
|
||||
FileLoader *fileloader;
|
||||
Zone_Model *zm;
|
||||
FILE *fff;
|
||||
EQFileType FileType = UNKNOWN;
|
||||
|
||||
|
||||
sprintf(bufs, "%s.s3d", shortname);
|
||||
|
||||
archive = new PFSLoader();
|
||||
fff = fopen(bufs, "rb");
|
||||
if(fff != nullptr)
|
||||
if(fff != nullptr)
|
||||
FileType = S3D;
|
||||
else {
|
||||
sprintf(bufs, "%s.eqg", shortname);
|
||||
@@ -92,7 +92,7 @@ bool ProcessZoneFile(const char *shortname) {
|
||||
bool V4Zone = false;
|
||||
|
||||
switch(FileType) {
|
||||
case S3D:
|
||||
case S3D:
|
||||
fileloader = new WLDLoader();
|
||||
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
|
||||
printf("Error reading WLD from %s\n", bufs);
|
||||
@@ -118,7 +118,7 @@ bool ProcessZoneFile(const char *shortname) {
|
||||
|
||||
|
||||
zm = fileloader->model_data.zone_model;
|
||||
|
||||
|
||||
if(!V4Zone)
|
||||
ListPlaceable(fileloader, bufs);
|
||||
else
|
||||
@@ -137,11 +137,11 @@ void ListPlaceable(FileLoader *fileloader, char *ZoneFileName) {
|
||||
fileloader->model_data.placeable[i]->x,
|
||||
fileloader->model_data.placeable[i]->z,
|
||||
fileloader->model_data.placeable[i]->model,
|
||||
fileloader->model_data.models[fileloader->model_data.placeable[i]->model]->name);
|
||||
fileloader->model_data.models[fileloader->model_data.placeable[i]->model]->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ListPlaceableV4(FileLoader *fileloader, char *ZoneFileName)
|
||||
{
|
||||
|
||||
@@ -175,7 +175,7 @@ void ListPlaceableV4(FileLoader *fileloader, char *ZoneFileName)
|
||||
list<int>::iterator ModelIterator;
|
||||
|
||||
ModelIterator = (*Iterator).SubObjects.begin();
|
||||
|
||||
|
||||
while(ModelIterator != (*Iterator).SubObjects.end())
|
||||
{
|
||||
int SubModel = (*ModelIterator);
|
||||
|
||||
@@ -46,12 +46,12 @@ inline void decompress(char *p, char *p2, int len, int uLen) {
|
||||
d_stream.zalloc = (alloc_func)0;
|
||||
d_stream.zfree = (free_func)0;
|
||||
d_stream.opaque = (voidpf)0;
|
||||
|
||||
|
||||
d_stream.next_in = (Bytef *) p;
|
||||
d_stream.avail_in = len;
|
||||
d_stream.next_out = (Bytef *) p2;
|
||||
d_stream.avail_out = uLen;
|
||||
|
||||
|
||||
inflateInit(&d_stream);
|
||||
status = inflate(&d_stream, Z_NO_FLUSH);
|
||||
inflateEnd(&d_stream);
|
||||
@@ -107,7 +107,7 @@ int PFSLoader::Open(FILE *fp)
|
||||
|
||||
fseek(fp, s3d_header.offset, SEEK_SET);
|
||||
fread(&s3d_dir_header, sizeof(struct_directory_header), 1, fp);
|
||||
|
||||
|
||||
this->count = s3d_dir_header.count - 1;
|
||||
this->filenames = new char *[s3d_dir_header.count];
|
||||
this->files = new uint32[s3d_dir_header.count - 1];
|
||||
@@ -206,7 +206,7 @@ const char *PFSLoader::FindExtension(const char *ext) {
|
||||
int i;
|
||||
|
||||
int elen = strlen(ext);
|
||||
|
||||
|
||||
for(i = 0; i < this->count; ++i) {
|
||||
int flen = strlen(this->filenames[i]);
|
||||
if(flen <= elen)
|
||||
@@ -234,7 +234,7 @@ int PFSLoader::GetFile(char *name, uchar **buf, int *len) {
|
||||
fread(&s3d_dir, sizeof(struct_directory), 1, this->fp);
|
||||
fseek(this->fp, s3d_dir.offset, SEEK_SET);
|
||||
*buf = new uchar[s3d_dir.size];
|
||||
|
||||
|
||||
inf = 0;
|
||||
while(inf < (int)s3d_dir.size) {
|
||||
fread(&s3d_data, sizeof(struct_data_block), 1, this->fp);
|
||||
|
||||
+10
-10
@@ -105,17 +105,17 @@ int TERLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
|
||||
this->model_data.zone_model = new Zone_Model;
|
||||
zm = this->model_data.zone_model;
|
||||
|
||||
|
||||
zm->vert_count = thdr->vert_count;
|
||||
zm->poly_count = thdr->tri_count;
|
||||
|
||||
|
||||
zm->verts = new Vertex *[zm->vert_count];
|
||||
zm->polys = new Polygon *[zm->poly_count];
|
||||
|
||||
this->model_data.plac_count = 0;
|
||||
this->model_data.model_count = 0;
|
||||
|
||||
buffer = ter_orig + thdr->list_len + sizeof(ter_header);
|
||||
|
||||
buffer = ter_orig + thdr->list_len + sizeof(ter_header);
|
||||
if(thdr->magic[3] == 'M') buffer = buffer + 4;
|
||||
#ifdef DEBUGTER
|
||||
printf("Starting offset is %8X\n", buffer-ter_orig);
|
||||
@@ -158,7 +158,7 @@ int TERLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
j = 0;
|
||||
for(i = 0; i < (unsigned int)zm->poly_count; ++i) {
|
||||
ttri = (ter_triangle *) buffer;
|
||||
@@ -167,7 +167,7 @@ int TERLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
continue;
|
||||
}
|
||||
zm->polys[j] = new Polygon;
|
||||
/*
|
||||
/*
|
||||
zm->polys[j]->v1 = ttri->v1;
|
||||
zm->polys[j]->v2 = ttri->v2;
|
||||
zm->polys[j]->v3 = ttri->v3;
|
||||
@@ -201,15 +201,15 @@ int TERLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
#endif
|
||||
zm->polys[j]->tex = ttri->group;
|
||||
}
|
||||
|
||||
|
||||
++j;
|
||||
buffer += sizeof(ter_triangle);
|
||||
}
|
||||
|
||||
|
||||
zm->poly_count = j;
|
||||
|
||||
|
||||
zm->tex_count = 0;
|
||||
|
||||
|
||||
delete[] mlist;
|
||||
|
||||
delete [] ter_orig;
|
||||
|
||||
+16
-16
@@ -150,11 +150,11 @@ FRAG_CONSTRUCTOR(Data21) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
FRAG_CONSTRUCTOR(Data22) {
|
||||
|
||||
|
||||
int pos;
|
||||
|
||||
uchar *data6area ;
|
||||
@@ -190,7 +190,7 @@ FRAG_CONSTRUCTOR(Data22) {
|
||||
Frag36Ref = *((long *) (data6area+20));
|
||||
//printf("Frag 36 reference?: %ld\n", *((long *) (data6area+20)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ FRAG_CONSTRUCTOR(Data22) {
|
||||
}
|
||||
|
||||
FRAG_CONSTRUCTOR(Data29) {
|
||||
|
||||
|
||||
long a,flags, numregions, lenstr;
|
||||
|
||||
struct_Data29 *data29 = (struct_Data29 *) malloc(sizeof(struct_Data29));
|
||||
@@ -213,7 +213,7 @@ FRAG_CONSTRUCTOR(Data29) {
|
||||
else if(!strncmp((char *) &wld->sHash[-frag_name], "VWA", 3)) data29->region_type = 7; // VWater ?
|
||||
|
||||
this->frag = (void *) data29;
|
||||
|
||||
|
||||
flags = *buf;
|
||||
numregions = *((long *)(buf+4));
|
||||
data29->region_count = numregions ;
|
||||
@@ -277,7 +277,7 @@ FRAG_CONSTRUCTOR(Data30) {
|
||||
this->frag = (void *) tex;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tex = (Texture *) wld->frags[ref - 1]->frag;
|
||||
|
||||
if(data->params1 & (1 << 1) || data->params1 & (1 << 2) || data->params1 & (1 << 3) || data->params1 & (1 << 4))
|
||||
@@ -313,7 +313,7 @@ FRAG_CONSTRUCTOR(Data36) {
|
||||
VertexNormal *vn;
|
||||
Vert *v;
|
||||
|
||||
|
||||
|
||||
|
||||
TexRef *tr;
|
||||
|
||||
@@ -393,7 +393,7 @@ FRAG_CONSTRUCTOR(Data36) {
|
||||
|
||||
|
||||
for(i = 0; i < header->normalsCount; ++i) {
|
||||
|
||||
|
||||
if(i<header->vertexCount) {
|
||||
vn = (VertexNormal *) buf;
|
||||
vert = model->verts[i];
|
||||
@@ -419,7 +419,7 @@ FRAG_CONSTRUCTOR(Data36) {
|
||||
// in the WLD loader in the stock azone, and has the effect of screwing up the normals,
|
||||
// Changed to keep things consistent with prior versions.
|
||||
poly->v1 = p->v1;
|
||||
poly->v2 = p->v2;
|
||||
poly->v2 = p->v2;
|
||||
poly->v3 = p->v3;
|
||||
#ifdef DEBUGWLD2
|
||||
printf("Frag36: Polygon: %5d Vertices: %5d, %5d, %5d\n", i, poly->v1, poly->v2, poly->v3);
|
||||
@@ -502,7 +502,7 @@ int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
return 0;
|
||||
|
||||
buffer += sizeof(struct_wld_header);
|
||||
|
||||
|
||||
this->sHash = buffer;
|
||||
decode(this->sHash, header->stringHashSize);
|
||||
buffer += header->stringHashSize;
|
||||
@@ -535,7 +535,7 @@ int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
case 0x30: FRAGMENT(Data30); break;
|
||||
case 0x31: FRAGMENT(Data31); break;
|
||||
case 0x36: FRAGMENT(Data36); break;
|
||||
|
||||
|
||||
default: this->frags[i] = new Fragment; break;
|
||||
}
|
||||
|
||||
@@ -545,7 +545,7 @@ int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
buffer += frag->size - 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(!strcmp(&zone_name[strlen(zone_name) - 4], "_obj")) {
|
||||
@@ -585,12 +585,12 @@ int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
zm->verts = new Vertex *[zm->vert_count];
|
||||
zm->polys = new Polygon *[zm->poly_count];
|
||||
|
||||
|
||||
vc = pc = 0;
|
||||
|
||||
|
||||
for(i = 0; i < this->fragcount; ++i) {
|
||||
if(this->frags[i]->type != 0x36)
|
||||
continue;
|
||||
@@ -714,7 +714,7 @@ int WLDLoader::Close() {
|
||||
for(j = 0; j < zm->tex_count; ++j)
|
||||
delete zm->tex[j];
|
||||
delete[] zm->tex;
|
||||
|
||||
|
||||
delete[] zm->verts;
|
||||
delete[] zm->polys;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class WLDLoader : public FileLoader {
|
||||
public:
|
||||
WLDLoader();
|
||||
~WLDLoader();
|
||||
|
||||
|
||||
virtual int Open(char *base_path, char *zone_name, Archive *archive);
|
||||
virtual int Close();
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
// Derision: 23/06/08
|
||||
// dranikcatacombsa.eqg has a couple of model names with a left parenthesis where there should
|
||||
// be an underscore. E.g. OBP_DZ_Lbanner0)_00.MOD instead of OBP_DZ_Lbanner0__00.MOD
|
||||
// This is the only zone I have seen this in, but is the reason for the follow code to replace
|
||||
// This is the only zone I have seen this in, but is the reason for the follow code to replace
|
||||
// the parenthesis with an underscore.
|
||||
//
|
||||
for(unsigned int i=0; i<strlen(model_names[ModelNumber]); i++)
|
||||
@@ -173,7 +173,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
|
||||
|
||||
|
||||
// Skip over the
|
||||
// Skip over the
|
||||
buffer = zon_orig + hdr->list_len + hdr->NumberOfModels * 4;
|
||||
|
||||
this->model_data.plac_count = hdr->obj_count - 1;
|
||||
@@ -187,8 +187,8 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
#ifdef DEBUGPLAC
|
||||
printf(" Placeable count is %d\n", this->model_data.plac_count);
|
||||
#endif
|
||||
this->model_data.placeable = new Placeable *[this->model_data.plac_count];
|
||||
|
||||
this->model_data.placeable = new Placeable *[this->model_data.plac_count];
|
||||
|
||||
plac = (zon_placeable *) buffer;
|
||||
base[0] = plac->x;
|
||||
base[1] = plac->y;
|
||||
@@ -250,7 +250,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
long UnknownSize = *((long *)(buffer));
|
||||
buffer = buffer + 4 + (UnknownSize * 4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
}
|
||||
// printf("Attempting to open MOD file %s\n", model_names[j]); fflush(stdout);
|
||||
if(model_loaders[j].Open(nullptr, model_names[j], archive)) {
|
||||
|
||||
|
||||
this->model_data.models[j] = new Model;
|
||||
this->model_data.models[j]->vert_count = model_loaders[j].model_data.zone_model->vert_count;
|
||||
this->model_data.models[j]->poly_count = model_loaders[j].model_data.zone_model->poly_count;
|
||||
@@ -282,10 +282,10 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
this->model_data.models[j]->tex = model_loaders[j].model_data.zone_model->tex;
|
||||
this->model_data.models[j]->name = new char[strlen(model_names[j])+1];
|
||||
strcpy(this->model_data.models[j]->name, model_names[j]);
|
||||
|
||||
|
||||
tex_tmp = 1;
|
||||
// I think this is looking to see if the placeable model textures already exist in the zone model.
|
||||
//
|
||||
//
|
||||
for(i = 0; i < this->model_data.models[j]->tex_count; ++i) {
|
||||
tex_tmp = 1; // Derision
|
||||
for(k = 0; k < this->model_data.zone_model->tex_count; ++k) {
|
||||
@@ -310,7 +310,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
|
||||
continue;
|
||||
}
|
||||
for(l = 0; l < this->model_data.models[k]->tex_count; ++l) {
|
||||
if(this->model_data.models[k]->tex[l]->filenames[0] == this->model_data.models[j]->tex[i]->filenames[0] ||
|
||||
if(this->model_data.models[k]->tex[l]->filenames[0] == this->model_data.models[j]->tex[i]->filenames[0] ||
|
||||
(this->model_data.models[k]->tex[l]->filenames[0] &&
|
||||
this->model_data.models[j]->tex[i]->filenames[0] &&
|
||||
!strcmp(this->model_data.models[k]->tex[l]->filenames[0], this->model_data.models[j]->tex[i]->filenames[0]))) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class ZonLoader : public FileLoader {
|
||||
public:
|
||||
ZonLoader();
|
||||
~ZonLoader();
|
||||
|
||||
|
||||
virtual int Open(char *base_path, char *zone_name, Archive *archive);
|
||||
virtual int Close();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Zonv4Loader::~Zonv4Loader()
|
||||
|
||||
int Zonv4Loader::Open(char *base_path, char *zone_name, Archive *archive)
|
||||
{
|
||||
|
||||
|
||||
uchar *buffer;
|
||||
int position;
|
||||
int buf_len;
|
||||
|
||||
@@ -31,7 +31,7 @@ class Zonv4Loader : public FileLoader {
|
||||
public:
|
||||
Zonv4Loader();
|
||||
~Zonv4Loader();
|
||||
|
||||
|
||||
virtual int Open(char *base_path, char *zone_name, Archive *archive);
|
||||
virtual int Close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user