1 | /* |
1 | /* |
2 | * static char *rcsid_object_c = |
2 | * static char *rcsid_object_c = |
3 | * "$Id: object.C,v 1.8 2006/08/29 08:01:35 root Exp $"; |
3 | * "$Id: object.C,v 1.9 2006/08/30 06:06:26 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
2618 | /* Also remember that multiparts objects are not supported for now. */ |
2618 | /* Also remember that multiparts objects are not supported for now. */ |
2619 | |
2619 | |
2620 | object* load_object_str(const char *obstr) |
2620 | object* load_object_str(const char *obstr) |
2621 | { |
2621 | { |
2622 | object *op; |
2622 | object *op; |
2623 | FILE *tempfile; |
|
|
2624 | char filename[MAX_BUF]; |
2623 | char filename[MAX_BUF]; |
2625 | sprintf(filename,"%s/cfloadobstr2044",settings.tmpdir); |
2624 | sprintf(filename,"%s/cfloadobstr2044",settings.tmpdir); |
|
|
2625 | |
2626 | tempfile=fopen(filename,"w"); |
2626 | FILE *tempfile=fopen(filename,"w"); |
2627 | if (tempfile == NULL) |
2627 | if (tempfile == NULL) |
2628 | { |
2628 | { |
2629 | LOG(llevError,"Error - Unable to access load object temp file\n"); |
2629 | LOG(llevError,"Error - Unable to access load object temp file\n"); |
2630 | return NULL; |
2630 | return NULL; |
2631 | }; |
2631 | }; |
2632 | fprintf(tempfile,obstr); |
2632 | fprintf(tempfile,obstr); |
2633 | fclose(tempfile); |
2633 | fclose(tempfile); |
2634 | |
2634 | |
2635 | op=get_object(); |
2635 | op=get_object(); |
2636 | |
2636 | |
2637 | tempfile=fopen(filename,"r"); |
|
|
2638 | if (tempfile == NULL) |
|
|
2639 | { |
|
|
2640 | LOG(llevError,"Error - Unable to read object temp file\n"); |
|
|
2641 | return NULL; |
|
|
2642 | }; |
|
|
2643 | object_thawer thawer (tempfile); |
2637 | object_thawer thawer (filename); |
|
|
2638 | if (thawer) |
2644 | load_object(thawer,op,LO_NEWFILE,0); |
2639 | load_object(thawer,op,LO_NEWFILE,0); |
2645 | LOG(llevDebug," load str completed, object=%s\n",op->name); |
2640 | LOG(llevDebug," load str completed, object=%s\n",op->name); |
2646 | CLEAR_FLAG(op,FLAG_REMOVED); |
2641 | CLEAR_FLAG(op,FLAG_REMOVED); |
2647 | fclose(tempfile); |
2642 | |
2648 | return op; |
2643 | return op; |
2649 | } |
2644 | } |
2650 | |
2645 | |
2651 | /* This returns the first object in who's inventory that |
2646 | /* This returns the first object in who's inventory that |
2652 | * has the same type and subtype match. |
2647 | * has the same type and subtype match. |