Contraptions Design Specification

Section 3.8.x : Widget Pointers

By Kenneth Manta

A giant ant, pointing. Who me? no there!(behind)


Note:the death script pointer has been deleted. Possibly create a CScriptPtr class that stores a single pointer to a script if it exists. //I Broke ships serializing widget pointers

Widget Pointers


Every widget is assigned a unique ID number when added to a session. If a ship containing them is split, the widget pointers will carry correctly to the split ship.
Ships are also reffered to by widget pointers. Since ships can split in half they must always be referred to by a specific widget on them.

Creating widget pointers
These are currently implemented very poorly
DWORD Session.ShipToWidgetPtr(Ship,X,Y)
bool Session.WidgetPtrToShip(CWidgetPointerInfo*)

Widget pointer audit.



I broke ClearFromMask for widget pointers

When a ship is added to a sim all of its widgets aquire pointers.

CWidgetPointer{
	CWidgetPointer();
	~CWidgetPointer();
//Widget Functions
	Rebind(Ship,X,Y);//During ship splits the Ship and/or xy position change
	Bind(Ship,X,Y);//Aquires a new ID
	BindID(ID,Ship,X,Y);//Bind a specific ID
	Clear();
private:
	Serialize();//On load, informs the widget pointer map(Remap)
	DWORD Ptr;
};

CWidgetReference{
//App Functions
	GetShip();
	GetX();
	GetY();

	Point(CShip *Ship, int X, int Y);//Set this ID to another ship's ID
	Serialize?
private:
	DWORD Ptr;
};


//The pointer map will LogError if it fails to find a widget
//A verify command should be made that LogErrors if any ships have either duplicate pointers or a pointer higher than the NextID 
CWidgetPointerMap{
	CWidgetPointerMap();
	~CWidgetPointerMap();
	Add(CWidgetPointer *,Ship *,X,Y);//Binds the widget pointer to the widget[x][y] on ship. Creates a new ID
	Delete(PointerID);
	Remap(PointerID,Ship,X,Y);
	Clear();
	
	DWORD NextID;
	
	Serialize();//Just stores the NextID
};

Critical Widget Pointer code sections

The following are all the code sections that add, delete, or remap a widget pointer


Copyright 2004-2005 © Polyart. All rights reserved.