mirror of
https://github.com/sfall-team/int2ssl.git
synced 2026-07-27 16:52:42 -07:00
Code formating
This commit is contained in:
+48
-39
@@ -1,19 +1,12 @@
|
||||
// Opcode.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Opcode.h"
|
||||
#include "Utility.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// Globals
|
||||
extern int g_nFalloutVersion;
|
||||
|
||||
|
||||
// COpcode
|
||||
|
||||
COpcode::COpcode() :
|
||||
m_wOperator(O_NOOP),
|
||||
m_ulArgument(0)
|
||||
@@ -41,41 +34,47 @@ COpcode& COpcode::operator = (const COpcode& opcode)
|
||||
|
||||
void COpcode::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ReadMSBWord(ar, m_wOperator) != OPERATOR_SIZE) {
|
||||
if (ReadMSBWord(ar, m_wOperator) != OPERATOR_SIZE)
|
||||
{
|
||||
printf("Error: Unable read opcode\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
printf("Error: Unable read opcode\n");
|
||||
if ((m_wOperator < O_OPERATOR) ||
|
||||
((m_wOperator >= O_END_OP) &&
|
||||
(m_wOperator != O_STRINGOP) &&
|
||||
(m_wOperator != O_FLOATOP)&&
|
||||
(m_wOperator != O_INTOP)))
|
||||
{
|
||||
ar.Flush();
|
||||
printf("Error: Invalid opcode at 0x%08x\n", ar.GetFile()->GetPosition() - 2);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))
|
||||
{
|
||||
if (ReadMSBULong(ar, m_ulArgument) != ARGUMENT_SIZE)
|
||||
{
|
||||
printf("Error: Unable read opcode argument\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if ((m_wOperator < O_OPERATOR) ||
|
||||
((m_wOperator >= O_END_OP) &&
|
||||
(m_wOperator != O_STRINGOP) &&
|
||||
(m_wOperator != O_FLOATOP)&&
|
||||
(m_wOperator != O_INTOP))) {
|
||||
ar.Flush();
|
||||
printf("Error: Invalid opcode at 0x%08x\n", ar.GetFile()->GetPosition() - 2);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) {
|
||||
if (ReadMSBULong(ar, m_ulArgument) != ARGUMENT_SIZE) {
|
||||
printf("Error: Unable read opcode argument\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void COpcode::Expect(CArchive& ar, WORD wOperator, BOOL bArgumentFound, ULONG ulArgument)
|
||||
{
|
||||
Serialize(ar);
|
||||
|
||||
if (m_wOperator != wOperator) {
|
||||
if (m_wOperator != wOperator)
|
||||
{
|
||||
printf("Error: Unexpected opcode (0x%04X expected, but 0x%04X found)\n", wOperator, m_wOperator);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
if (bArgumentFound && ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))) {
|
||||
if (m_ulArgument != ulArgument) {
|
||||
if (bArgumentFound && ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)))
|
||||
{
|
||||
if (m_ulArgument != ulArgument)
|
||||
{
|
||||
printf("Error: Unexpected argument of opcode. (0x%08X expected, but 0x%08X found)\n", ulArgument, m_ulArgument);
|
||||
AfxThrowUserException();
|
||||
}
|
||||
@@ -87,18 +86,23 @@ void COpcode::Expect(CArchive& ar, int nCount, WORD pwOperators[])
|
||||
Serialize(ar);
|
||||
BOOL bFound = FALSE;
|
||||
|
||||
for(int i = 0; i < nCount; i++) {
|
||||
if (m_wOperator == pwOperators[i]) {
|
||||
for(int i = 0; i < nCount; i++)
|
||||
{
|
||||
if (m_wOperator == pwOperators[i])
|
||||
{
|
||||
bFound = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFound) {
|
||||
if (!bFound)
|
||||
{
|
||||
printf("Error: Unexpected opcode (");
|
||||
|
||||
for(int i = 0; i < nCount; i++) {
|
||||
if (i != 0) {
|
||||
for(int i = 0; i < nCount; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
printf(" or ");
|
||||
}
|
||||
|
||||
@@ -117,10 +121,12 @@ BOOL COpcode::HasArgument() const
|
||||
|
||||
int COpcode::GetSize() const
|
||||
{
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) {
|
||||
if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))
|
||||
{
|
||||
return OPERATOR_SIZE + ARGUMENT_SIZE;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return OPERATOR_SIZE;
|
||||
}
|
||||
}
|
||||
@@ -147,13 +153,16 @@ const COpcode::COpcodeAttributes COpcode::GetAttributes() const
|
||||
|
||||
COpcodeAttributes result;
|
||||
|
||||
if (g_nFalloutVersion == 1) {
|
||||
if (f1OpcodeAttributes.Lookup(m_wOperator, result)) {
|
||||
if (g_nFalloutVersion == 1)
|
||||
{
|
||||
if (f1OpcodeAttributes.Lookup(m_wOperator, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!f2OpcodeAttributes.Lookup(m_wOperator, result)) {
|
||||
if (!f2OpcodeAttributes.Lookup(m_wOperator, result))
|
||||
{
|
||||
printf("Error: Attempt to obtain attributes of unknown opcode\n");
|
||||
AfxThrowUserException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user