//===========================================================================//
// File:	l4msson.cc                                                          //
// Project: MUNGA           Brick: Application     								  //
// Contents: Implementation Details for missions   								  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 02/19/95  JMA  Initial coding.                                            //
// 09/12/95  JM	Put Back in Munga Added Munga L4 level Player Data			  //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//
#if 0
//			THIS FILE IS OBSOLETE AS OF 11-1-95 cpb


#include "l4munga.hpp"

#if !defined(L4MSSN_HPP)
#	include "l4mssn.hpp"
#endif

#if !defined(L4HOST_HPP)
#	include "l4host.hpp"
#endif

#if !defined(MISSION_HPP)
#	include "mission.hpp"
#endif

//##########################################################################
//##########################   L4Mission    ################################
//##########################################################################

//
//#############################################################################
//#############################################################################
//
L4Mission::L4Mission(
	NotationFile *notation_file,
	ResourceFile *resources
):
	Mission(notation_file, resources)
{
	for(int i=0; i < Player::numberOfNameBitmaps; ++i)
	{
		nameBitmap[i] = NULL;
	}
}

//
//#############################################################################
//#############################################################################
//
L4Mission::~L4Mission()
{
	for(int i=0; i<Player::numberOfNameBitmaps; ++i)
	{
		if (nameBitmap[i] != NULL)
		{
			Check(nameBitmap[i]);
			Unregister_Object(nameBitmap[i]);
			delete nameBitmap[i];
		}
	}
}

//
//#############################################################################
//#############################################################################
//
void
	L4Mission::SetPlayerData(
		NotationFile *notation_file
	)
{
	Check(this);
	Check(notation_file);

	//
	//--------------------------------------------------------------
	// Figure out which page we should be using to create the player
	//--------------------------------------------------------------
	//
	Check(application);
	HostManager *host_manager = application->GetHostManager();
	Check(host_manager);
	L4Host *host = (L4Host*)host_manager->GetLocalHost();
	Check(host);
	CString player_node = host->GetSymbolicName();

	//
	//-----------------
	// Get Vehicle name
	//-----------------
	//
	gameModel = NULL;
	const char* player_model = NULL;
	notation_file->GetEntry(player_node, "vehicle", &player_model);
	if (!player_model)
	{
		DEBUG_STREAM << "Error: vehicle not specified!\n";
		Exit(1);
	}
	Check_Pointer(player_model);
	gameModel = strdup(player_model);
	Register_Pointer(gameModel);
   //
	//-----------------
	// Get DropZone name
	//-----------------
	//
	dropZoneName = NULL;
	const char* drop_zone = NULL;
	notation_file->GetEntry(player_node, "dropzone", &drop_zone);
	if (!drop_zone)
	{
		DEBUG_STREAM << "Error: dropzone not specified!\n";
		Exit(1);
	}
	Check_Pointer(drop_zone);
	dropZoneName = strdup(drop_zone);
	Register_Pointer(dropZoneName);
	//
	//------------------
	// Set DropZone Host
	//------------------
	//
	dropZoneHost = False;
	notation_file->GetEntry(player_node, "loadzones", &dropZoneHost);
   //
	//-----------------
	// Get Color name
	//-----------------
	//
   colorName = NULL;
	const char* color_name = NULL;
	notation_file->GetEntry(player_node, "color", &color_name);
	if (!color_name)
	{
		DEBUG_STREAM << "Error: color not specified!\n";
		Exit(1);
	}
	Check_Pointer(color_name);
	colorName = strdup(color_name);
	Register_Pointer(colorName);
   //
	//-----------------
	// Get Badge name
	//-----------------
	//
	badgeName = NULL;
	const char* badge_name = NULL;
	notation_file->GetEntry(player_node, "badge", &badge_name);
	if (!badge_name)
	{
		DEBUG_STREAM << "Error: badge not specified!\n";
		Exit(1);
	}
	Check_Pointer(badge_name);
	badgeName = strdup(badge_name);
	Register_Pointer(badgeName);

   //
	//-----------------------------------------------
	// Get the Role name "General" if not listed
	//-----------------------------------------------
	//
	positionName = NULL;
	const char* position_name = NULL;
	notation_file->GetEntry(player_node, "position", &position_name);
	if(!position_name)
	{
		position_name = strdup("General");
	}
	Check_Pointer(position_name);
	positionName = strdup(position_name);
	Register_Pointer(positionName);
	//
	//---------------------------------------
	// Assign an integer value for the teamID
	//---------------------------------------
	//
	const char* team_name;
	notation_file->GetEntry(player_node, "team", &team_name);
	int team_count;

	NameList
		*team_namelist = notation_file->MakeEntryList("teams");

	teamID = -1;
	if (team_namelist)
	{
		Register_Object(team_namelist);
		team_count = team_namelist->EntryCount();
		if(team_count)
		{
			int  current_id=0;
			NameList::Entry *team_entry = team_namelist->GetFirstEntry();
			while(team_entry)
			{
				if (strcmp(team_name, team_entry->GetChar()) == 0)
				{
					teamID = current_id;
					break;
				}
				current_id++;
				team_entry = team_entry->GetNextEntry();
			}
		}
		Unregister_Object(team_namelist);
		delete team_namelist;
	}
}

//
//#############################################################################
//#############################################################################
//
Logical
	L4Mission::TestInstance() const
{
	Mission::TestInstance();
	return True;
}
#endif
