I love the smell of UnrealEd crashing in the morning. – tarquin

Difference between revisions of "UE1:NBSPCrc (Class)"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(Discussion)
(Discussion)
Line 14: Line 14:
 
* Perform hashing operations on every chunk of 255 bytes read from the file, this is done in the SendBinary function<br>
 
* Perform hashing operations on every chunk of 255 bytes read from the file, this is done in the SendBinary function<br>
 
<br>
 
<br>
 +
--[[User:AnthraX|AnthraX]] 16:51, 22 May 2009 (UTC)
  
 
== Complete source code ==
 
== Complete source code ==

Revision as of 09:51, 22 May 2009

Purpose

The WebResponse class is most likely extended to create a limited file reader to perform CRC checks.

Variables

Discussion

As the name suggests, WebResponse was originally intended as a "Response" object from the webadmin and other WebApplications to the client. Epic added the possibility to include attachments in the response from the server to the client. By calling the IncludeBinaryFile function you can read a binary file. The engine then reads the file in chunks of 255 bytes, adds the bytes to a TArray<BYTE> structure and calls the SendBinary function.

The original WebResponse just passes the data to the WebConnection.SendBinary function, but by overriding the WebResponse.SendBinary function, certain operations, such as hashing can be performed. Long story short, every unrealscript filechecker does the following to check a file:

  • Set the IncludePath, which is the folder from where the file will be read
  • Call the IncludeBinaryFile function with the name of the file as the argument
  • Perform hashing operations on every chunk of 255 bytes read from the file, this is done in the SendBinary function


--AnthraX 16:51, 22 May 2009 (UTC)

Complete source code

//=============================================================================
// NBSPCrc ==> NoBullShitPlus v1.09
//=============================================================================
 
class NBSPCrc extends WebResponse;
 
var private int q, a, x;
 
function HTTPResponse (string Header) {} //SEND HEADER
function SendStandardHeaders (optional string ContentType) {}
function Redirect (string URL) {}
event SendBinary (int b, byte ab[255])
{
	local int zzi, ti;
	const c = 0xedb82633;
 
	for (zzi=0;zzi<x;zzi++)
		a += ((ab[zzi] * ab[zzi]) + ((ab[zzi] - q)^ab[zzi]) ^ c) * ab[zzi];
}
final function ss(private int g) { q = g; }
final function ac(private int y) { x = y; }
final function int gg() { return a; }
final function dd() { a=0; }
 
defaultproperties
{
     IncludePath=""
}