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

📄 configmgr.cpp

📁 Blood 2全套源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
;
;	 MODULE:		ConfigMgr (.CPP)
;
;	PURPOSE:		Config Manager for .b2c files
;
;	HISTORY:		10/15/98 [blg] This file was created
;
;	COMMENT:		Copyright (c) 1998, Monolith Productions Inc.
;
****************************************************************************/


// Includes...

#include "Windows.h"
#include "ConfigMgr.h"
#include "Direct.h"
#include "StdIo.h"
#include "Io.h"
#include "..\Shared\ClientRes.h"
#include <mbstring.h>

// Statics...

char	s_sText[128];


// Functions...

/* *********************************************************************** */
/* CConfig                                                                 */

// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CConfig::Init
//
//	PURPOSE:	Initialization
//
// ----------------------------------------------------------------------- //

BOOL CConfig::Init(char* sFilename)
{
	// Sanity checks...

	if (!sFilename) return(FALSE);
	if (sFilename[0] == '\0') return(FALSE);


	// Set simple members...

	_mbsncpy((unsigned char*)m_sDisplay, (const unsigned char*)sFilename, CM_MAX_NAME - 1);
	_mbsncpy((unsigned char*)m_sFile, (const unsigned char*)sFilename, CM_MAX_NAME - 1);


	// Strip off the file extension...

	if (_mbsstr((const unsigned char*)m_sDisplay, (const unsigned char*)"."))
	{
		int nLen = _mbstrlen(m_sDisplay);
		if (nLen > 4) m_sDisplay[nLen - 4] = '\0';
	}


	// Open the file and read the values...

	FILE* pFile = fopen(m_sFile, "rb");
	if (!pFile) return(FALSE);

	int cBytes = fread(&m_B2c, 1, sizeof(B2C), pFile);

	fclose(pFile);

	if (cBytes != sizeof(B2C)) return(FALSE);


	// Do a non-add-on check if...

#ifndef _ADDON
	if (m_B2c.dwCharacter > 3)
	{
		return(FALSE);
	}
#endif


	// All done...

	return(TRUE);
}


// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CConfig::Init
//
//	PURPOSE:	Initialization
//
// ----------------------------------------------------------------------- //

BOOL CConfig::FillDialog(HWND hDlg)
{
	// Sanity checks...

	if (!hDlg) return(FALSE);


	// Set the character and color...

	SetDlgItemText(hDlg, IDC_CHARACTER, GetCharacterAndColor());


	// Set the four main attributes...

	SetDlgItemText(hDlg, IDC_STRENGTH, GetStrength());
	SetDlgItemText(hDlg, IDC_SPEED, GetSpeed());
	SetDlgItemText(hDlg, IDC_RESIST, GetResist());
	SetDlgItemText(hDlg, IDC_FOCUS, GetFocus());


	// Set the weapon lines...

	SetDlgItemText(hDlg, IDC_WEAP1, GetWeaponLine1());
	SetDlgItemText(hDlg, IDC_WEAP2, GetWeaponLine2());
	SetDlgItemText(hDlg, IDC_WEAP3, GetWeaponLine3());


	// All done...

	return(TRUE);
}

char* CConfig::GetCharacterAndColor()
{
	char sChar[32];
	char sColor[32];

	_mbscpy((unsigned char*)sChar, (const unsigned char*)GetCharacter());
	_mbscpy((unsigned char*)sColor, (const unsigned char*)GetColor());

	sprintf(s_sText, "%s (%s)", sChar, sColor);
	return(s_sText);
}

char* CConfig::GetCharacter()
{
	switch (m_B2c.dwCharacter)
	{
		case CHARACTER_CALEB:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Caleb"); break;
		case CHARACTER_OPHELIA:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Ophelia"); break;
		case CHARACTER_ISHMAEL:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Ishmael"); break;
		case CHARACTER_GABREILLA:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Gabriella"); break;

#ifdef _ADDON
		case CHARACTER_M_CULTIST:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Male Cultist"); break;
		case CHARACTER_F_CULTIST:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Female Cultist"); break;
		case CHARACTER_SOULDRUDGE:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Soul Drudge"); break;
		case CHARACTER_PROPHET:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Prophet"); break;
#endif

		default: _mbscpy((unsigned char*)s_sText, (const unsigned char*)"Caleb");
	}

	return(s_sText);
}

char* CConfig::GetColor()
{
	switch (m_B2c.dwColor)
	{
		case MULTIPLAY_SKIN_NORMAL: _mbscpy((unsigned char*)s_sText, (const unsigned char*)"Normal"); break;
		case MULTIPLAY_SKIN_RED:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Red"); break;
		case MULTIPLAY_SKIN_BLUE:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Blue"); break;
		case MULTIPLAY_SKIN_GREEN:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Green"); break;
		case MULTIPLAY_SKIN_YELLOW: _mbscpy((unsigned char*)s_sText, (const unsigned char*)"Yellow"); break;

		default: _mbscpy((unsigned char*)s_sText, (const unsigned char*)"Normal");
	}

	return(s_sText);
}

char* CConfig::GetStrength()
{
	sprintf(s_sText, "%i", m_B2c.dwStrength);
	return(s_sText);
}

char* CConfig::GetSpeed()
{
	sprintf(s_sText, "%i", m_B2c.dwSpeed);
	return(s_sText);
}

char* CConfig::GetResist()
{
	sprintf(s_sText, "%i", m_B2c.dwResist);
	return(s_sText);
}

char* CConfig::GetFocus()
{
	sprintf(s_sText, "%i", m_B2c.dwFocus);
	return(s_sText);
}

char* CConfig::GetWeapon(DWORD dwWeap)
{
	switch (dwWeap)
	{
		case WEAP_NONE:				_mbscpy((unsigned char*)s_sText, (const unsigned char*)"None"); break;
		case WEAP_BERETTA:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Brta"); break;
		case WEAP_SUBMACHINEGUN:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Sub"); break;
		case WEAP_FLAREGUN:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Flare"); break;
		case WEAP_SHOTGUN:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Shot"); break;
		case WEAP_SNIPERRIFLE:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Snipe"); break;
		case WEAP_HOWITZER:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Howtz"); break;
		case WEAP_NAPALMCANNON:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Naplm"); break;
		case WEAP_SINGULARITY:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Sing"); break;
		case WEAP_ASSAULTRIFLE:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Aslt"); break;
		case WEAP_BUGSPRAY:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Bug"); break;
		case WEAP_MINIGUN:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Mini"); break;
		case WEAP_DEATHRAY:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Death"); break;
		case WEAP_TESLACANNON:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Tesla"); break;
		case WEAP_VOODOO:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Voodoo"); break;
		case WEAP_ORB:				_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Orb"); break;
		case WEAP_LIFELEECH:		_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Leech"); break;
#ifdef _ADD_ON
		case WEAP_COMBATSHOTGUN:	_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Combat"); break;
		case WEAP_FLAYER:			_mbscpy((unsigned char*)s_sText, (const unsigned char*)"Flayer"); break;
#endif

		default: _mbscpy((unsigned char*)s_sText, (const unsigned char*)"N/A");
	}

	return(s_sText);
}

char* CConfig::GetWeaponLine1()
{
	char s1[32];
	char s2[32];
	char s3[32];

	_mbscpy((unsigned char*)s1, (const unsigned char*)GetWeapon(m_B2c.dwWeap1));
	_mbscpy((unsigned char*)s2, (const unsigned char*)GetWeapon(m_B2c.dwWeap2));
	_mbscpy((unsigned char*)s3, (const unsigned char*)GetWeapon(m_B2c.dwWeap3));

	sprintf(s_sText, "%s, %s, %s", s1, s2, s3);
	return(s_sText);
}

char* CConfig::GetWeaponLine2()
{
	char s1[32];
	char s2[32];
	char s3[32];

	_mbscpy((unsigned char*)s1, (const unsigned char*)GetWeapon(m_B2c.dwWeap4));
	_mbscpy((unsigned char*)s2, (const unsigned char*)GetWeapon(m_B2c.dwWeap5));
	_mbscpy((unsigned char*)s3, (const unsigned char*)GetWeapon(m_B2c.dwWeap6));

	sprintf(s_sText, "%s, %s, %s", s1, s2, s3);
	return(s_sText);
}

char* CConfig::GetWeaponLine3()
{
	char s1[32];
	char s2[32];
	char s3[32];

	_mbscpy((unsigned char*)s1, (const unsigned char*)GetWeapon(m_B2c.dwWeap7));
	_mbscpy((unsigned char*)s2, (const unsigned char*)GetWeapon(m_B2c.dwWeap8));
	_mbscpy((unsigned char*)s3, (const unsigned char*)GetWeapon(m_B2c.dwWeap9));

	sprintf(s_sText, "%s, %s, %s", s1, s2, s3);
	return(s_sText);
}


/* *********************************************************************** */
/* CConfigMgr                                                              */

// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CConfigMgr::Init
//
//	PURPOSE:	Initialization
//
// ----------------------------------------------------------------------- //

BOOL CConfigMgr::Init(char* sDir)
{
	// Sanity checks...

	if (!sDir) return(FALSE);
	if (sDir[0] == '\0') return(FALSE);


	// Terminate everything...

	Term();


	// Change to the given direcotry...

	if (chdir(sDir) != 0)
	{
		return(FALSE);
	}


	// Enumerate the available .b2c files and add them to the list box...

	long	hFile;
    struct	_finddata_t fd;

	hFile = _findfirst("*.b2c", &fd);
	if (hFile == -1)
	{
		chdir("..");
		return(FALSE);
	}

⌨️ 快捷键说明

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