mirror of
https://github.com/tbamud/tbamud.git
synced 2026-02-09 01:14:21 +01:00
The basis for 'oset'
This commit is contained in:
parent
870bb8ef38
commit
2939a3d507
7 changed files with 221 additions and 0 deletions
110
src/genobj.c
110
src/genobj.c
|
|
@ -11,11 +11,13 @@
|
|||
#include "utils.h"
|
||||
#include "db.h"
|
||||
#include "shop.h"
|
||||
#include "constants.h"
|
||||
#include "genolc.h"
|
||||
#include "genobj.h"
|
||||
#include "genzon.h"
|
||||
#include "dg_olc.h"
|
||||
#include "handler.h"
|
||||
#include "interpreter.h"
|
||||
#include "boards.h" /* for board_info */
|
||||
|
||||
|
||||
|
|
@ -474,3 +476,111 @@ int delete_object(obj_rnum rnum)
|
|||
|
||||
return rnum;
|
||||
}
|
||||
|
||||
/* oset handling, this location should be temporary */
|
||||
bool oset_alias(struct obj_data *obj, char * argument)
|
||||
{
|
||||
static int max_len = 64;
|
||||
int i = GET_OBJ_RNUM(obj);
|
||||
|
||||
skip_spaces(&argument);
|
||||
|
||||
if (strlen(argument) > max_len)
|
||||
return FALSE;
|
||||
|
||||
if (obj->name && obj->name != obj_proto[i].name)
|
||||
free(obj->name);
|
||||
|
||||
obj->name = strdup(argument);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool oset_apply(struct obj_data *obj, char * argument)
|
||||
{
|
||||
int i = 0, apply = -1, location = -1, mod = 0, empty = -1, value;
|
||||
char arg[MAX_INPUT_LENGTH];
|
||||
|
||||
argument = one_argument(argument, arg);
|
||||
|
||||
skip_spaces(&argument);
|
||||
|
||||
if ((value = atoi(argument)) == 0)
|
||||
return FALSE;
|
||||
|
||||
while (*apply_types[i] != '\n') {
|
||||
if (is_abbrev(apply_types[i], arg)) {
|
||||
apply = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (apply == -1)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < MAX_OBJ_AFFECT; i++) {
|
||||
if (obj->affected[i].location == apply) {
|
||||
location = i;
|
||||
mod = obj->affected[i].modifier;
|
||||
break;
|
||||
} else if (obj->affected[i].location == APPLY_NONE && empty == -1) {
|
||||
empty = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* No slot already using APPLY_XXX, so use an empty one... if available */
|
||||
if (location == -1)
|
||||
location = empty;
|
||||
|
||||
/* There is no slot already using our APPLY_XXX type, and no empty slots either */
|
||||
if (location == -1)
|
||||
return FALSE;
|
||||
|
||||
obj->affected[location].modifier = mod + value;
|
||||
|
||||
/* Our modifier is set at 0, so lets just clear the apply location so that it may
|
||||
* be reused at a later point */
|
||||
if (obj->affected[location].modifier != 0)
|
||||
obj->affected[location].location = apply;
|
||||
else
|
||||
obj->affected[location].location = APPLY_NONE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool oset_short_description(struct obj_data *obj, char * argument)
|
||||
{
|
||||
static int max_len = 64;
|
||||
int i = GET_OBJ_RNUM(obj);
|
||||
|
||||
skip_spaces(&argument);
|
||||
|
||||
if (strlen(argument) > max_len)
|
||||
return FALSE;
|
||||
|
||||
if (obj->short_description && obj->short_description != obj_proto[i].short_description)
|
||||
free(obj->short_description);
|
||||
|
||||
obj->short_description = strdup(argument);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool oset_long_description(struct obj_data *obj, char * argument)
|
||||
{
|
||||
static int max_len = 128;
|
||||
int i = GET_OBJ_RNUM(obj);
|
||||
|
||||
skip_spaces(&argument);
|
||||
|
||||
if (strlen(argument) > max_len)
|
||||
return FALSE;
|
||||
|
||||
if (obj->description && obj->description != obj_proto[i].description)
|
||||
free(obj->description);
|
||||
|
||||
obj->description = strdup(argument);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue