//===========================================================================//
// File:	Driver_Tool.cpp																	  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 03/08/99  DPB  Created File                             //
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#include "AdeptHeaders.hpp"

#include "Driver.hpp"
#include "Tool.hpp"
#include "Map.hpp"
#include "DropZone.hpp"
#include "NameTable.hpp"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	Driver__CreateMessage::ConstructCreateMessage(Script *script)
{
	Check_Object(script);
	#if defined(_ARMOR)
		int stack_level = Tool::Instance->GetStackLevel();
	#endif

	//
	//--------------
	// Set up stream
	//--------------
	//
	MemoryStream *message_stream = script->messageStream;
	Check_Object(message_stream);
	message_stream->AllocateBytes(sizeof(Driver__CreateMessage));
	Entity::CreateMessage::ConstructCreateMessage(script);
	Verify(stack_level == Tool::Instance->GetStackLevel());
	Driver__CreateMessage *message =
		Cast_Pointer(
			Driver__CreateMessage*,
			message_stream->GetPointer()
		);
	message->messageLength = sizeof(*message);

	//
	//---------------------------------------------------------------
	// Point at the notation file and make other files relative to it
	//---------------------------------------------------------------
	//
	Page *page = script->instancePage;
	Check_Object(page);
	Check_Object(Tool::Instance);

	//
	//------------------
	//Does use drop zone
	//------------------
	//
	message->dropZone = NameTable::NullObjectID;

	const char *drop_zone = "";
	page->GetEntry("DropZone", &drop_zone);
	if(NameTable::GetInstance())
	{
		Check_Object(NameTable::GetInstance());
		message->dropZone = NameTable::GetInstance()->FindID(drop_zone);
	}

	Verify(stack_level == Tool::Instance->GetStackLevel());
}
