forked from Mirrors/openclonk
unifdef C4GROUP and C4FRONTEND
The frontend is dead anyway, and c4group doesn't even use the affected files. Except C4Update, where I replaced a printf with ::Log.stable-5.2
parent
09a7f4cd07
commit
1ce653fd40
|
@ -243,18 +243,6 @@ class C4Group: public CStdStream
|
|||
bool fStartAtFilename=false);
|
||||
bool Read(void *pBuffer, size_t iSize);
|
||||
bool Advance(int iOffset);
|
||||
#ifdef C4FRONTEND
|
||||
// Stuff for the FE
|
||||
bool LoadIcon(const char *szEntryname, HICON *lphIcon);
|
||||
bool ReadDDB(HBITMAP *lphBitmap, HDC hdc = NULL);
|
||||
bool ReadDDBSection(HBITMAP *lphBitmap, HDC hdc,
|
||||
int iSecX, int iSecY, int iSecWdt, int iSecHgt,
|
||||
int iImgWdt=-1, int iImgHgt=-1,
|
||||
BOOL fTransCol = FALSE);
|
||||
bool ReadPNGSection(HBITMAP *lphBitmap, HDC hdc,
|
||||
int iSecX, int iSecY, int iSecWdt, int iSecHgt,
|
||||
int iImgWdt=-1, int iImgHgt=-1);
|
||||
#endif
|
||||
void SetMaker(const char *szMaker);
|
||||
void SetPassword(const char *szPassword);
|
||||
void SetStdOutput(BOOL fStatus);
|
||||
|
@ -315,15 +303,6 @@ class C4Group: public CStdStream
|
|||
C4GroupEntry *GetEntry(const char *szName);
|
||||
C4GroupEntry *SearchNextEntry(const char *szName);
|
||||
C4GroupEntry *GetNextFolderEntry();
|
||||
#ifdef C4FRONTEND
|
||||
HBITMAP SubReadDDB(HDC hdc,
|
||||
int sx=-1, int sy=-1, int swdt=-1, int shgt=-1,
|
||||
int twdt=-1, int thgt=-1,
|
||||
BOOL transcol=FALSE);
|
||||
HBITMAP SubReadPNG(HDC hdc,
|
||||
int sx=-1, int sy=-1, int swdt=-1, int shgt=-1,
|
||||
int twdt=-1, int thgt=-1);
|
||||
#endif
|
||||
bool CalcCRC32(C4GroupEntry *pEntry);
|
||||
};
|
||||
|
||||
|
|
|
@ -52,10 +52,6 @@
|
|||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#ifdef C4FRONTEND
|
||||
#include "C4Group.h"
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
bool isGermanSystem()
|
||||
{
|
||||
|
|
|
@ -43,11 +43,6 @@
|
|||
#include <C4Material.h>
|
||||
#endif
|
||||
|
||||
#if defined(C4FRONTEND) || defined(C4GROUP)
|
||||
#include "C4Group.h"
|
||||
#include "C4Scenario.h"
|
||||
#include "C4CompilerWrapper.h"
|
||||
#endif
|
||||
|
||||
//-------------------------- Default Action Procedures --------------------------------------
|
||||
|
||||
|
@ -521,10 +516,6 @@ C4Def::~C4Def()
|
|||
|
||||
void C4Def::Clear()
|
||||
{
|
||||
#ifdef C4FRONTEND
|
||||
if (Picture) DeleteObject(Picture); Picture=NULL;
|
||||
if (Image) DeleteObject(Image); Image=NULL;
|
||||
#endif
|
||||
|
||||
Graphics.Clear();
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
#include <C4Game.h>
|
||||
#endif
|
||||
|
||||
#if defined(C4FRONTEND) || defined (C4GROUP)
|
||||
#include "C4CompilerWrapper.h"
|
||||
#endif
|
||||
|
||||
//================= C4FolderHead ====================
|
||||
|
||||
|
|
|
@ -2168,249 +2168,6 @@ bool C4Group::Add(const char *szName, StdStrBuf &pBuffer, bool fChild, bool fHol
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef C4FRONTEND
|
||||
HBITMAP C4Group::SubReadDDB(HDC hdc,
|
||||
int sx, int sy, int swdt, int shgt,
|
||||
int twdt, int thgt,
|
||||
BOOL transcol)
|
||||
{
|
||||
HBITMAP hbmp;
|
||||
BITMAPFILEHEADER fhead;
|
||||
BITMAPINFO* pbmi = (BITMAPINFO*) new BYTE[sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD)];
|
||||
long bfoffs;
|
||||
BYTE fbuf;
|
||||
uint8_t *bmpbits;
|
||||
const BOOL f256Only=TRUE; // Format accept flag
|
||||
|
||||
// Read and check file header
|
||||
if (!Read(&fhead,sizeof(fhead))) { delete pbmi; return NULL; }
|
||||
if (fhead.bfType!= *((WORD*)"BM") ) { delete pbmi; return NULL; }
|
||||
|
||||
// Read and check bitmap info header
|
||||
if (!Read(&(pbmi->bmiHeader),sizeof(BITMAPINFOHEADER))) { delete pbmi; return NULL; }
|
||||
if (f256Only)
|
||||
if ((pbmi->bmiHeader.biBitCount!=8) || (pbmi->bmiHeader.biCompression!=0))
|
||||
{ delete pbmi; return NULL; }
|
||||
if (!pbmi->bmiHeader.biSizeImage) { delete pbmi; return NULL; }
|
||||
|
||||
// Read colors
|
||||
if (!Read(pbmi->bmiColors,256*sizeof(RGBQUAD))) { delete pbmi; return NULL; }
|
||||
|
||||
if (transcol)
|
||||
{
|
||||
pbmi->bmiColors[0].rgbRed=0xFF;
|
||||
pbmi->bmiColors[0].rgbBlue=0xFF;
|
||||
pbmi->bmiColors[0].rgbGreen=0x00;
|
||||
}
|
||||
|
||||
// Read offset to pixels
|
||||
for (bfoffs=fhead.bfOffBits-sizeof(BITMAPFILEHEADER)-sizeof(BITMAPINFOHEADER)-256*sizeof(RGBQUAD); bfoffs>0; bfoffs--)
|
||||
if (!Read(&fbuf,1))
|
||||
{ delete pbmi; return NULL; }
|
||||
|
||||
// Read the pixels
|
||||
int iBufferSize = pbmi->bmiHeader.biHeight*DWordAligned(pbmi->bmiHeader.biWidth);
|
||||
if (!(bmpbits=new uint8_t [iBufferSize])) { delete pbmi; return NULL; }
|
||||
if (!Read(bmpbits,iBufferSize))
|
||||
{ delete [] bmpbits; delete pbmi; return NULL; }
|
||||
|
||||
// Cut bitmap to section if desired
|
||||
if ((sx>-1) && (sy>-1) && (swdt>-1) && (shgt>-1))
|
||||
{
|
||||
if (twdt==-1) twdt=swdt; if (thgt==-1) thgt=shgt;
|
||||
|
||||
if (sx+swdt>pbmi->bmiHeader.biWidth){ delete pbmi; return NULL; }
|
||||
if (sy+shgt>pbmi->bmiHeader.biHeight) { delete pbmi; return NULL; }
|
||||
|
||||
int tbufwdt=twdt; DWordAlign(tbufwdt);
|
||||
int tbufhgt=thgt;
|
||||
int sbufwdt=pbmi->bmiHeader.biWidth; DWordAlign(sbufwdt);
|
||||
int sbufhgt=pbmi->bmiHeader.biHeight;
|
||||
uint8_t *tbuf;
|
||||
if (tbuf = new uint8_t [tbufhgt*tbufwdt])
|
||||
{
|
||||
ZeroMem(tbuf,tbufhgt*tbufwdt);
|
||||
BufferBlitAspect(bmpbits,sbufwdt,sbufhgt, sx,sy,swdt,shgt,
|
||||
tbuf,tbufwdt,tbufhgt, 0,0,twdt,thgt);
|
||||
delete [] bmpbits;
|
||||
bmpbits=tbuf;
|
||||
pbmi->bmiHeader.biSizeImage=tbufwdt*tbufhgt;
|
||||
pbmi->bmiHeader.biWidth=twdt;
|
||||
pbmi->bmiHeader.biHeight=thgt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create the bitmap
|
||||
hbmp= (HBITMAP) CreateDIBitmap(hdc,
|
||||
(BITMAPINFOHEADER*) &(pbmi->bmiHeader),
|
||||
CBM_INIT,
|
||||
bmpbits,
|
||||
(BITMAPINFO*) pbmi,
|
||||
DIB_RGB_COLORS
|
||||
);
|
||||
|
||||
delete [] bmpbits;
|
||||
delete pbmi;
|
||||
|
||||
return hbmp;
|
||||
}
|
||||
|
||||
bool C4Group::ReadDDB(HBITMAP *lphBitmap, HDC hdc)
|
||||
{
|
||||
BOOL fOwnHDC=FALSE;
|
||||
if (!lphBitmap) return FALSE;
|
||||
// Check DC
|
||||
if (!hdc) { hdc= (HDC) GetDC(NULL); fOwnHDC=TRUE; }
|
||||
// Read bitmap
|
||||
*lphBitmap=SubReadDDB(hdc);
|
||||
// Release DC
|
||||
if (fOwnHDC) ReleaseDC(NULL,hdc);
|
||||
if (!(*lphBitmap)) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool C4Group::ReadDDBSection(HBITMAP *lphBitmap, HDC hdc,
|
||||
int iSecX, int iSecY, int iSecWdt, int iSecHgt,
|
||||
int iImgWdt, int iImgHgt, BOOL fTransCol)
|
||||
{
|
||||
BOOL fOwnHDC=FALSE;
|
||||
// Init & argument check
|
||||
if (!lphBitmap) return FALSE;
|
||||
// Check DC
|
||||
if (!hdc) { hdc= (HDC) GetDC(NULL); fOwnHDC=TRUE; }
|
||||
// Read bitmap
|
||||
*lphBitmap=SubReadDDB(hdc,iSecX,iSecY,iSecWdt,iSecHgt,iImgWdt,iImgHgt,fTransCol);
|
||||
// Release DC
|
||||
if (fOwnHDC) ReleaseDC(NULL,hdc);
|
||||
if (!(*lphBitmap)) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void BltAlpha2(DWORD &dwDst, DWORD dwSrc)
|
||||
{
|
||||
BYTE byAlphaDst=(BYTE)(dwSrc>>24); BYTE byAlphaSrc=255-byAlphaDst;
|
||||
BYTE *pPixChanD = (BYTE *) &dwDst;
|
||||
BYTE *pPixChanS = (BYTE *) &dwSrc;
|
||||
*pPixChanD = (((int) *pPixChanD * byAlphaDst) >> 8) + (((int) *pPixChanS * byAlphaSrc) >> 8); ++pPixChanS; ++pPixChanD;
|
||||
*pPixChanD = (((int) *pPixChanD * byAlphaDst) >> 8) + (((int) *pPixChanS * byAlphaSrc) >> 8); ++pPixChanS; ++pPixChanD;
|
||||
*pPixChanD = (((int) *pPixChanD * byAlphaDst) >> 8) + (((int) *pPixChanS * byAlphaSrc) >> 8);
|
||||
}
|
||||
|
||||
HBITMAP C4Group::SubReadPNG(HDC hdc,
|
||||
int sx, int sy, int swdt, int shgt,
|
||||
int twdt, int thgt)
|
||||
{
|
||||
// read data
|
||||
int iSize = AccessedEntrySize();
|
||||
if (!iSize) return 0;
|
||||
BYTE *pData = new BYTE[iSize];
|
||||
if (!Read(pData, iSize)) { delete [] pData; return 0; }
|
||||
|
||||
// load png
|
||||
CPNGFile png;
|
||||
if (!png.Load(pData, iSize)) { delete [] pData; return 0; }
|
||||
|
||||
// free compressed data
|
||||
delete [] pData;
|
||||
|
||||
// create DIB bitmap
|
||||
BITMAPINFO bmi; ZeroMemory(&bmi, sizeof(bmi));
|
||||
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
|
||||
bmi.bmiHeader.biWidth = png.iWdt;
|
||||
bmi.bmiHeader.biHeight = (int)png.iHgt;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
// read into mem; reverse orientation; render against white bg; make transparent pixels have purple bg
|
||||
DWORD *tbuf = new DWORD[png.iWdt*png.iHgt];
|
||||
DWORD *pdwBuf = tbuf;
|
||||
for (int y=(int)png.iHgt-1; y>=0; --y) for (int x=0; x<(int)png.iWdt; ++x)
|
||||
{
|
||||
DWORD dwPix = png.GetPix(x,y);
|
||||
DWORD dwWhite;
|
||||
if (dwPix & 0xa0000000)
|
||||
{
|
||||
dwWhite = 0xff00ff;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwWhite = 0xffffff;
|
||||
BltAlpha2(dwWhite, dwPix);
|
||||
}
|
||||
*pdwBuf++ = dwWhite;
|
||||
}
|
||||
|
||||
// No section specified, but target size specified: use full image as section
|
||||
if ((sx == -1) && (sy == -1) && (swdt == -1) && (shgt == -1))
|
||||
if ((twdt > -1) && (thgt > -1))
|
||||
{ sx = 0; sy = 0; swdt = png.iWdt; shgt = png.iHgt; }
|
||||
|
||||
// cut bitmap to section if desired
|
||||
if ((sx>-1) && (sy>-1) && (swdt>-1) && (shgt>-1))
|
||||
{
|
||||
if (twdt==-1) twdt=swdt; if (thgt==-1) thgt=shgt;
|
||||
|
||||
if (sx+swdt>(int)png.iWdt || sy+shgt>(int)png.iHgt) { delete [] tbuf; return 0; }
|
||||
|
||||
int tbufwdt=twdt; DWordAlign(tbufwdt);
|
||||
int tbufhgt=thgt;
|
||||
int sbufwdt=png.iWdt;
|
||||
int sbufhgt=png.iHgt;
|
||||
|
||||
DWORD *tbuf2 = new DWORD[tbufhgt*tbufwdt];
|
||||
|
||||
// Fill target buffer with purple background color
|
||||
int iFill = tbufhgt * tbufwdt;
|
||||
while (iFill)
|
||||
tbuf2[--iFill] = 0x00ff00ff;
|
||||
//FillMemory(tbuf2, tbufhgt * tbufwdt, 0xff); ...this was double - and it was incorrect buffer size??
|
||||
|
||||
BufferBlitAspectDw(reinterpret_cast<uint32_t *>(tbuf),sbufwdt,sbufhgt, sx,sy,swdt,shgt,
|
||||
reinterpret_cast<uint32_t *>(tbuf2),tbufwdt,tbufhgt, 0,0,twdt,thgt);
|
||||
|
||||
delete [] tbuf; tbuf=tbuf2;
|
||||
|
||||
bmi.bmiHeader.biSizeImage=tbufwdt*tbufhgt*png.GetBitsPerPixel()/8;
|
||||
bmi.bmiHeader.biWidth=twdt;
|
||||
bmi.bmiHeader.biHeight=thgt;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
// Create the bitmap
|
||||
HBITMAP hbmp= (HBITMAP) CreateDIBitmap(hdc,
|
||||
&(bmi.bmiHeader),
|
||||
CBM_INIT,
|
||||
(BYTE *)tbuf,
|
||||
&bmi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
// free image buffer
|
||||
delete [] tbuf;
|
||||
|
||||
return hbmp;
|
||||
}
|
||||
|
||||
bool C4Group::ReadPNGSection(HBITMAP *lphBitmap, HDC hdc,
|
||||
int iSecX, int iSecY, int iSecWdt, int iSecHgt,
|
||||
int iImgWdt, int iImgHgt)
|
||||
{
|
||||
BOOL fOwnHDC=FALSE;
|
||||
// Init & argument check
|
||||
if (!lphBitmap) return FALSE;
|
||||
// Check DC
|
||||
if (!hdc) { hdc= (HDC) GetDC(NULL); fOwnHDC=TRUE; }
|
||||
// Read bitmap
|
||||
*lphBitmap=SubReadPNG(hdc,iSecX,iSecY,iSecWdt,iSecHgt,iImgWdt,iImgHgt);
|
||||
// Release DC
|
||||
if (fOwnHDC) ReleaseDC(NULL,hdc);
|
||||
if (!(*lphBitmap)) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
#endif //C4ENGINE
|
||||
|
||||
const char* C4Group::GetName()
|
||||
{
|
||||
|
@ -2623,28 +2380,6 @@ C4Group* C4Group::GetMother()
|
|||
return Mother;
|
||||
}
|
||||
|
||||
#ifdef C4FRONTEND
|
||||
bool C4Group::LoadIcon(const char *szEntryname, HICON *lphIcon)
|
||||
{
|
||||
if (!szEntryname || !lphIcon) return FALSE;
|
||||
|
||||
*lphIcon = NULL;
|
||||
|
||||
BYTE *bpBuf; unsigned int iSize;
|
||||
if (!LoadEntry(szEntryname,reinterpret_cast<char **>(&bpBuf),&iSize))
|
||||
return FALSE;
|
||||
|
||||
*lphIcon = CreateIconFromResource(bpBuf,iSize,TRUE,0x00030000);
|
||||
|
||||
DWORD err = GetLastError();
|
||||
|
||||
delete [] bpBuf;
|
||||
|
||||
if (*lphIcon)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
#endif //C4FRONTEND
|
||||
|
||||
int C4Group::GetStatus()
|
||||
{
|
||||
|
|
|
@ -35,10 +35,6 @@
|
|||
|
||||
#include <C4Random.h>
|
||||
|
||||
#if defined(C4FRONTEND) || defined(C4GROUP)
|
||||
#include "C4CompilerWrapper.h"
|
||||
#include "C4Def.h"
|
||||
#endif
|
||||
|
||||
//------------------------------- Player Info ----------------------------------------
|
||||
|
||||
|
|
|
@ -42,9 +42,6 @@
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef C4FRONTEND
|
||||
#include "C4CompilerWrapper.h"
|
||||
#endif
|
||||
|
||||
int32_t MVehic=MNone,MTunnel=MNone,MWater=MNone,MSnow=MNone,MEarth=MNone,MGranite=MNone,MFlyAshes=MNone;
|
||||
BYTE MCVehic=0;
|
||||
|
|
|
@ -32,9 +32,6 @@
|
|||
#include <C4Game.h>
|
||||
#endif
|
||||
|
||||
#if defined(C4FRONTEND) || defined (C4GROUP)
|
||||
#include "C4CompilerWrapper.h"
|
||||
#endif
|
||||
|
||||
//==================================== C4SVal ==============================================
|
||||
|
||||
|
|
|
@ -22,12 +22,7 @@
|
|||
#include "C4Group.h"
|
||||
#include "C4Log.h"
|
||||
|
||||
#ifdef C4FRONTEND
|
||||
#include "C4ExplorerCfg.h"
|
||||
C4ExplorerCfg *GetCfg();
|
||||
#else
|
||||
C4Config *GetCfg();
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
|
@ -853,7 +848,5 @@ void C4UpdatePackage::WriteLog(const char *strMsg, ...)
|
|||
vsprintf(strOutp, strMsg, arglist);
|
||||
Log.Write(strOutp, strlen(strOutp));
|
||||
Log.Flush();
|
||||
#ifdef C4GROUP
|
||||
printf(strOutp);
|
||||
#endif
|
||||
::Log(strOutp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue