Files
firestorm/Gameleap/code/mw4/Libraries/stuff/SafeChain_Test.cpp
T
dicion af416960fa Translate Korean comments/strings to English; fix UTF-8 encoding across source tree
Korean translation (84 source files, 876 lines):
- Translated all EUC-KR/CP949 Korean developer comments to English across
  84 source files in Gameleap/code/. Zero Korean bytes remain outside the
  intentional font-table headers (D3FFontEdit2/fontedit all.h etc.).
- Comment markers: //상훈 앞/뒤 -> //sanghoon begin/end (Sang-hun's code
  region markers); //상훈짱 begin/end, //상훈.. variants; // 鉉 -> // hyun
  (second developer's markers); // 鉉 - start/end patterns.
- Functional string translations in recscore.cpp (mw4 + mw4print copies):
  body-part return values (왼발/오른발/etc. -> Left Leg/Right Leg/etc.),
  kill-announcer format strings (~30 entries), and the nonmfc.h assert dialog.
- GosView profiler: 킪 -> us (microseconds) in timing display strings.
- Network/socket code (ctcl.cpp, mugsocs.h, ctime.cpp across Launcher/
  MW4Application/MW4GameEd2/AnimScript): state-machine comments, socket
  ID comments, login/session management comments.
- render.hpp CHSH_Device member comments; GUIRadarManager.cpp drawing
  routine comments; hudchat/hudcomp2/huddamage/hudmap/hudweapon/hudtarg
  HUD component comments.
- DXRasterizer.cpp: cleaned residual U+FFFD replacement characters left
  from a prior partial encoding conversion.

UTF-8 encoding cleanup (76+ files):
- Latin-1 single bytes converted to proper UTF-8 multi-byte sequences:
  © (0xA9) in 3dsmax4/Maxscrpt Autodesk/Wainwright copyright headers,
  ® (0xAE) in gosHelp/Remote.cpp, · (0xB7) bullet points in ai command.hpp,
  Û (0xDB) in SafeChain_Test.cpp tool header,
  ß (0xDF) in AnimationSuite version strings (8 files).
- Font lookup tables (D3FFontEdit2/, fontedit/ *.h) intentionally left
  as-is: raw byte values are C array data, not text.

Language DLL:
- Replaced Gameleap/mw4/Language.dll (original Korean binary) and
  MW4/Language.dll with freshly built English version from
  Language - Win32 English config (Language.dsp). Fixes Korean button
  labels in the GameOS exception/crash dialog (??? ??... / ?? / ???
  were showing instead of More Details.../Continue/Exit).
2026-07-18 13:10:31 -05:00

525 lines
11 KiB
C++

//=======================================================================
// File: SCHNTST.CPP
//
// Created: Thursday, September 29, 1994, 2:37 PM
// Author: Eric Huffman
// Project: Node.Û
// Compiler: 7.0, Û Symantec Corporation 1994
//-----------------------------------------------------------------------
// 11/03/94 ECH Made compatible with BC4.0
//-----------------------------------------------------------------------
// Copyright (C) 1994, Virtual World Entertainments, All Rights reserved
// PROPRIETARY AND CONFIDENTIAL
//=======================================================================
#include "StuffHeaders.hpp"
#include <GameOS\ToolOS.hpp>
#define TEST_COUNT 50
class SafeChainTestPlug:
public Plug
{
public:
long value;
SafeChainTestPlug(long value);
~SafeChainTestPlug();
};
class SafeChainTestNode:
public Plug
{
public:
SafeChainOf<SafeChainTestPlug*>
chain1,
chain2;
SafeChainTestNode();
~SafeChainTestNode();
bool RunProfile();
bool RunTest();
};
SafeChainTestPlug::SafeChainTestPlug(long value):
Plug(DefaultData)
{
this->value = value;
}
SafeChainTestPlug::~SafeChainTestPlug()
{
}
SafeChainTestNode::SafeChainTestNode():
Plug(DefaultData), chain1(this), chain2(this)
{
}
SafeChainTestNode::~SafeChainTestNode()
{
}
//
//###########################################################################
// ProfileClass
//###########################################################################
//
void
SafeChain::ProfileClass()
{
SafeChainTestNode testNode;
#if defined(_ARMOR)
Time startTicks = gos_GetHiResTime();
#endif
Test_Message("SafeChain::ProfileClass");
testNode.RunProfile();
SPEW((
GROUP_STUFF_TEST,
"SafeChain::ProfileClass elapsed = %f",
gos_GetHiResTime() - startTicks
));
}
//
//###########################################################################
// TestClass
//###########################################################################
//
void
SafeChain::TestClass()
{
SPEW((GROUP_STUFF_TEST, "Starting SafeChain test..."));
SafeChainTestNode testNode;
testNode.RunTest();
}
bool
SafeChainTestNode::RunProfile()
{
SafeChainTestPlug *testPlug1;
int i;
Time startTicks;
//
//--------------------------------------------------------------------
// Run timing tests
//--------------------------------------------------------------------
//
/*
* Create plugs and add to both sockets
*/
startTicks = gos_GetHiResTime();
for (i = 0; i < TEST_COUNT; i++)
{
testPlug1 = new SafeChainTestPlug(i);
Register_Object( testPlug1 );
chain1.Add(testPlug1);
chain2.Add(testPlug1);
}
SPEW((
GROUP_STUFF_TEST,
"SafeChainTestNode::RunTest Create = %f",
gos_GetHiResTime() - startTicks
));
/*
* Iterate over both sockets
*/
startTicks = gos_GetHiResTime();
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
i = 0;
while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
{
Verify( testPlug1->value == i );
i++;
}
Verify( i == TEST_COUNT );
i = 0;
while ((testPlug1 = iterator2.ReadAndNext()) != NULL)
{
Verify( testPlug1->value == i );
i++;
}
Verify( i == TEST_COUNT );
}
SPEW((
GROUP_STUFF_TEST,
"SafeChainTestNode::RunTest Iterate = %f",
gos_GetHiResTime() - startTicks
));
/*
* Destroy from chain1, verify with chain2
*/
startTicks = gos_GetHiResTime();
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
i = 0;
while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
{
Verify( testPlug1->value == i );
i++;
Unregister_Object( testPlug1 );
delete(testPlug1);
}
Verify( i == TEST_COUNT );
Verify( iterator1.GetSize() == 0 );
Verify( iterator2.GetSize() == 0 );
}
SPEW((
GROUP_STUFF_TEST,
"SafeChainTestNode::RunTest Destroy = %f",
gos_GetHiResTime() - startTicks
));
return true;
}
bool
SafeChainTestNode::RunTest()
{
SafeChainTestPlug *testPlug1, *testPlug2;
int i, j;
// Time startTicks;
//
//--------------------------------------------------------------------
// Stress tests
//--------------------------------------------------------------------
//
/*
* Create plugs and add to both sockets
*/
for (i = 0; i < TEST_COUNT; i++)
{
testPlug1 = new SafeChainTestPlug(i);
Register_Object( testPlug1 );
chain1.Add(testPlug1);
chain2.Add(testPlug1);
}
/*
* Verify first and last
*/
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
iterator1.First();
iterator2.First();
testPlug1 = iterator1.GetCurrent();
testPlug2 = iterator2.GetCurrent();
Verify( testPlug1 == testPlug2 );
Verify( testPlug1 == iterator1.GetNth(0) );
Verify( testPlug1 == iterator2.GetNth(0) );
iterator1.Last();
iterator2.Last();
testPlug1 = iterator1.GetCurrent();
testPlug2 = iterator2.GetCurrent();
Verify( testPlug1 == testPlug2 );
Verify( testPlug1 == iterator1.GetNth(TEST_COUNT - 1) );
Verify( testPlug1 == iterator2.GetNth(TEST_COUNT - 1) );
}
/*
* Verify next and prev
*/
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
i = 0;
while ((testPlug1 = iterator1.GetCurrent()) != NULL)
{
testPlug2 = iterator2.GetCurrent();
Verify( testPlug1 == testPlug2 );
Verify( testPlug1->value == i );
Verify( testPlug2->value == i );
iterator1.Next();
iterator2.Next();
i++;
}
Verify( i == TEST_COUNT );
iterator1.Last();
iterator2.Last();
i = TEST_COUNT - 1;
while ((testPlug1 = iterator1.GetCurrent()) != NULL)
{
testPlug2 = iterator2.GetCurrent();
Verify( testPlug1 == testPlug2 );
Verify( testPlug1->value == i );
Verify( testPlug2->value == i );
iterator1.Previous();
iterator2.Previous();
i--;
}
Verify( i == -1 );
}
/*
* Verify read next and read prev
*/
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
i = 0;
while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
{
testPlug2 = iterator2.ReadAndNext();
Verify( testPlug1 == testPlug2 );
Verify( testPlug1->value == i );
Verify( testPlug2->value == i );
i++;
}
Verify( i == TEST_COUNT );
iterator1.Last();
iterator2.Last();
i = TEST_COUNT - 1;
while ((testPlug1 = iterator1.ReadAndPrevious()) != NULL)
{
testPlug2 = iterator2.ReadAndPrevious();
Verify( testPlug1 == testPlug2 );
Verify( testPlug1->value == i );
Verify( testPlug2->value == i );
i--;
}
Verify( i == -1 );
}
/*
* Verify nth
*/
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
for (i = 0; i < TEST_COUNT; i++)
{
testPlug1 = iterator1.GetNth(i);
testPlug2 = iterator2.GetNth(i);
Verify( testPlug1 == testPlug2 );
Verify( testPlug1->value == i );
Verify( testPlug2->value == i );
}
}
/*
* Verify Remove
*/
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
i = 0;
while ((testPlug1 = iterator1.GetCurrent()) != NULL)
{
Verify( testPlug1->value == i );
iterator1.Remove();
testPlug2 = iterator2.GetNth(0);
Verify( testPlug2->value == i );
Verify( testPlug1 == testPlug2 );
Unregister_Object( testPlug2 );
delete(testPlug2);
i++;
}
Verify( i == TEST_COUNT );
Verify( iterator1.GetSize() == 0 );
Verify( iterator2.GetSize() == 0 );
}
/*
* Verify random deletion
*/
{
/*
* Add plugs to both sockets
*/
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == 0 );
Verify( iterator2.GetSize() == 0 );
for (i = 0; i < TEST_COUNT; i++)
{
testPlug1 = new SafeChainTestPlug(i);
Register_Object( testPlug1 );
chain1.Add(testPlug1);
chain2.Add(testPlug1);
}
}
{
/*
* Perform random deletion
*/
int size, index;
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
Verify( iterator1.GetSize() == TEST_COUNT );
Verify( iterator2.GetSize() == TEST_COUNT );
i = 0;
while((size = iterator1.GetSize()) != 0)
{
index = Random::GetLessThan(size);
testPlug1 = iterator1.GetNth(index);
iterator1.Remove();
testPlug2 = iterator2.GetNth(index);
Verify( testPlug1 == testPlug2 );
Unregister_Object( testPlug2 );
delete(testPlug2);
i++;
}
Verify( i == TEST_COUNT );
Verify( iterator1.GetSize() == 0 );
Verify( iterator2.GetSize() == 0 );
}
/*
* Verify insertion
*/
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
Verify(iterator1.GetSize() == 0);
for (i = 0; i < TEST_COUNT; i++)
{
testPlug1 = new SafeChainTestPlug(i);
Register_Object(testPlug1);
if (i == 0)
{
chain1.Add(testPlug1);
}
else
{
iterator1.First();
iterator1.Insert(testPlug1);
}
}
for (i = 0, j = TEST_COUNT-1; i < TEST_COUNT; i++, j--)
{
testPlug1 = iterator1.GetNth(i);
Verify(testPlug1->value == j);
}
chain1.DeletePlugs();
}
{
SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
Verify(iterator1.GetSize() == 0);
for (i = 0; i < TEST_COUNT; i++)
{
testPlug1 = new SafeChainTestPlug(i);
Register_Object(testPlug1);
if (i == 0)
{
chain1.Add(testPlug1);
}
else
{
iterator1.Last();
iterator1.Insert(testPlug1);
}
}
for (i = 0; i < TEST_COUNT; i++)
{
testPlug1 = iterator1.GetNth(i);
if (i == TEST_COUNT-1)
{
Verify(testPlug1->value == 0);
}
else
{
Verify(testPlug1->value == i+1);
}
}
chain1.DeletePlugs();
}
return true;
}