Example #1
0
void CAeonRowValue::SetValue (CDatum dValue)

//	SetValue
//
//	Sets the value of a 0D row

	{
	CMemoryBuffer Buffer(4096);
	dValue.Serialize(CDatum::formatAEONScript, Buffer);

	//	Allocate a new block

	DWORD dwSizeUp = AlignUp(Buffer.GetLength(), (int)sizeof(DWORD));
	DWORD dwNewFixedBlockAlloc = sizeof(SItemHeader) + sizeof(SItemHeader) + dwSizeUp;
	void *pNewFixedBlock = new char [dwNewFixedBlockAlloc];

	//	Init

	SItemHeader *pHeader = (SItemHeader *)pNewFixedBlock;
	pHeader->dwSize = sizeof(SItemHeader) + dwSizeUp;

	SItemHeader *pItem = (SItemHeader *)&pHeader[1];
	pItem->dwSize = Buffer.GetLength();

	utlMemCopy(Buffer.GetPointer(), &pItem[1], Buffer.GetLength());

	//	Replace

	if (m_pFixedBlock && m_dwFixedBlockAlloc)
		delete m_pFixedBlock;
	m_pFixedBlock = pNewFixedBlock;
	m_dwFixedBlockAlloc = dwNewFixedBlockAlloc;
	}
Example #2
0
int ExecuteScript (const SOptions &Options)
	{
	int i, j;

	//	Load the script file

	CDatum dScript;
	CString sError;
	if (!CDatum::CreateFromFile(Options.sScriptFile, CDatum::formatAEONScript, &dScript, &sError))
		{
		printf("ERROR: %s\n", (LPSTR)sError);
		return 1;
		}

	//	Get the server to connect to

	CString sServer = dScript.GetElement(FIELD_SERVER);
	if (sServer.IsEmpty())
		sServer = Options.sServer;

	//	Connect

	CSocket theSocket;
	if (!ConnectToArcology(STR_ARC_CONSOLE, sServer, Options, &theSocket))
		return 1;

	//	Run the script

	CDatum dCommands = dScript.GetElement(FIELD_COMMANDS);
	for (i = 0; i < dCommands.GetCount(); i++)
		{
		CDatum dCommand = dCommands.GetElement(i);

		//	Generate a command-line from the command

		CStringBuffer Buffer;
		for (j = 0; j < dCommand.GetCount(); j++)
			{
			if (j != 0)
				Buffer.Write(" ", 1);

			dCommand.Serialize(CDatum::formatAEONScript, Buffer);
			}

		//	Run

		printf("%s\n", (LPSTR)(const CString &)Buffer);
		CString sResult = ExecuteArcologyCommand(theSocket, Buffer);
		PrintUTF8(sResult);
		printf("\n");
		}

	//	Done

	return 0;
	}