100 lines
2.5 KiB
C
100 lines
2.5 KiB
C
/*
|
|
* PVVMUD a 3D MUD
|
|
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
#include "pvvmud.H"
|
|
#include <stdlib.h>
|
|
#include <iostream.h>
|
|
#include "objectarray.H"
|
|
|
|
CObjectArray::CObjectArray(){
|
|
m_grow = -1;
|
|
m_size = 0;
|
|
m_num = 0;
|
|
m_array = NULL;
|
|
cdebug<< "WARNING: CObjectArray::CObjectArray FUNCTIONALITY NOT IMPLEMENTED!\n";
|
|
}
|
|
|
|
CObjectArray::CObjectArray(int size){
|
|
m_grow = 0;
|
|
m_size = size;
|
|
m_num = 0;
|
|
m_array = (CObject**)malloc(sizeof(CObject*)*size);
|
|
for (int ii = 0; ii < m_size; ii++) m_array[ii] = NULL;
|
|
}
|
|
|
|
CObjectArray::CObjectArray(int size,int grow){
|
|
m_grow = grow;
|
|
m_size = size;
|
|
m_num = 0;
|
|
m_array = (CObject**)malloc(sizeof(CObject*)*size);
|
|
for (int ii = 0; ii < m_size; ii++) m_array[ii] = NULL;
|
|
cdebug<< "WARNING: CObjectArray::CObjectArray FUNCTIONALITY NOT IMPLEMENTED!\n";
|
|
}
|
|
|
|
CObjectArray::~CObjectArray(){
|
|
if (m_array != NULL) free(m_array);
|
|
}
|
|
|
|
void CObjectArray::deleteList(){
|
|
m_num = 0;
|
|
}
|
|
|
|
void CObjectArray::deleteAll(){
|
|
while (m_num > 0){
|
|
m_num--;
|
|
delete m_array[m_num];
|
|
}
|
|
}
|
|
|
|
int CObjectArray::add(CObject * obj){
|
|
if (m_num < m_size){
|
|
int index = m_num++;
|
|
m_array[index] = obj;
|
|
return index;
|
|
} else {
|
|
cdebug << "WARNING: CObjectArray::add NOT IMPLEMENTED!\n";
|
|
}
|
|
}
|
|
|
|
void CObjectArray::insert(int index,CObject * obj){
|
|
cdebug << "WARNING: CObjectArray::insert NOT IMPLEMENTED!\n";
|
|
}
|
|
|
|
void CObjectArray::set(int index,CObject * obj){
|
|
m_array[index] = obj;
|
|
if (m_num <= index) m_num = index+1;
|
|
}
|
|
|
|
CObject* CObjectArray::getItem(int index){
|
|
return m_array[index];
|
|
}
|
|
|
|
void CObjectArray::remove(CObject * obj){
|
|
cdebug << "WARNING: CObjectArray::remove NOT IMPLEMENTED!\n";
|
|
}
|
|
|
|
void CObjectArray::remove(int index){
|
|
cdebug << "WARNING: CObjectArray::remove NOT IMPLEMENTED!\n";
|
|
}
|
|
|
|
int CObjectArray::getNumElements(){
|
|
return m_num;
|
|
}
|
|
|