File: equip.cc

package info (click to toggle)
starvoyager 0.4.4-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze
  • size: 1,508 kB
  • ctags: 922
  • sloc: cpp: 7,651; ansic: 825; sh: 129; makefile: 93
file content (72 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
	equip.cc
	
	(c) Richard Thrippleton
	Licensing terms are in the 'LICENSE' file
	If that file is not included with this source then permission is not given to use this source in any way whatsoever.
*/

#include <stdio.h>
#include "database.h"
#include "error.h"
#include "equip.h"

void equip::init()
{
}

void equip::loadlib()
{
	char nam[16]; //Object name to load equipment data from

	for(int i=0;i<LIBSIZE;i++)
	{
		sprintf(nam,"Equipment%hd",i);
		try
		{
			database::switchobj(nam);
			equips[i]=new equip(i);
			equips[i]->load();
		}
		catch(error it)
		{
		}
	}
}

equip* equip::get(int indx)
{
	if(indx>=0 && indx<LIBSIZE)
	{
		if(equips[indx])
			return equips[indx];
		else
			return NULL;
	}
	else
		return NULL;
}

equip::equip(int self)
{
	this->self=self;
}

void equip::load()
{
	database::getvalue("Name",nam);
	typ=database::getvalue("Type");
	mss=database::getvalue("Mass");
	spr=database::getvalue("Sprite");
	col=database::getvalue("Colour");
	snd=database::getvalue("Sound");
	pow=database::getvalue("Power");
	rdy=database::getvalue("CycleTime");
	cap=database::getvalue("Capacity");
	rng=database::getvalue("Range");
	trck=database::getvalue("Tracking");
	acov=database::getvalue("Coverage");
	cost=database::getvalue("Cost");
}

equip* equip::equips[LIBSIZE];