ai_list.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "ai_list.hpp"
00013
00014 void AIList::AddItem(int32 item, int32 value)
00015 {
00016 AIAbstractList::AddItem(item);
00017 this->SetValue(item, value);
00018 }
00019
00020 void AIList::ChangeItem(int32 item, int32 value)
00021 {
00022 this->SetValue(item, value);
00023 }
00024
00025 void AIList::RemoveItem(int32 item)
00026 {
00027 AIAbstractList::RemoveItem(item);
00028 }
00029
00030 SQInteger AIList::_set(HSQUIRRELVM vm)
00031 {
00032 if (sq_gettype(vm, 2) != OT_INTEGER) return SQ_ERROR;
00033 if (sq_gettype(vm, 3) != OT_INTEGER || sq_gettype(vm, 3) == OT_NULL) {
00034 return sq_throwerror(vm, _SC("you can only assign integers to this list"));
00035 }
00036
00037 SQInteger idx, val;
00038 sq_getinteger(vm, 2, &idx);
00039 if (sq_gettype(vm, 3) == OT_NULL) {
00040 this->RemoveItem(idx);
00041 return 0;
00042 }
00043
00044 sq_getinteger(vm, 3, &val);
00045 if (!this->HasItem(idx)) {
00046 this->AddItem(idx, val);
00047 return 0;
00048 }
00049
00050 this->ChangeItem(idx, val);
00051 return 0;
00052 }