File: cmdmemory.c

package info (click to toggle)
xshipwars 1.32-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 17,176 kB
  • ctags: 6,357
  • sloc: ansic: 157,152; makefile: 226; sh: 75
file content (129 lines) | stat: -rw-r--r-- 3,348 bytes parent folder | download
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "xsw.h"

#define THIS_CMD_NAME	"memory"

 
/*
 *      Print memory stats, reload configuration, or refresh and reclaim
 *	memory.
 */
int CmdMemory(char *arg)
{
	int events;
	xsw_mem_stat_struct buf;
        char text[PATH_MAX + NAME_MAX + 512];
        

        /* Get memory stats. */
        XSWGetProgMemory(&buf);


        /* Calculate memory consumed events. */
        events = OSWEventsPending();
 
        /* Print memory statistics. */
        if((arg == NULL) ? 1 : (arg[0] == '\0'))
        {
            sprintf(text,   
 "         total   intimgs    isrefs      objs     ocsns"
            );
            MesgAdd(text, xsw_color.standard_text);

            sprintf(text,
 "Mem:\
 %9ld\
 %9ld\
 %9ld\
 %9ld\
 %9ld",
                buf.total,
                buf.images,
                buf.isrefs,
                buf.objects,
                buf.ocsns
            );
            MesgAdd(text, xsw_color.standard_text);
            
            sprintf(text,
 "Ent:\
 %9ld\
 %9d\
 %9ld\
 %9ld\
 %9d",
                (long)(total_objects + total_isrefs + total_ocsns),
                total_images,
                total_isrefs,
                total_objects,
                total_ocsns
            );
            MesgAdd(text, xsw_color.standard_text);

            sprintf(text,
		"Usage: `%s [reload|refresh]'",
		THIS_CMD_NAME
            );
            MesgAdd(text, xsw_color.standard_text);
        }
        /* ********************************************************** */
        /* Reload files into memory? */
        else if(!strcasecmp(arg, "reload"))
        {
            sprintf(text,
    "Client: Memory reload: Main menu configuration from `%s'...",
                fname.main_menu_conf
            );
            MesgAdd(text, xsw_color.standard_text);
            XSWMainMenuLoadFromFile(
                &bridge_win.mm,
                bridge_win.viewscreen, bridge_win.viewscreen_image,
                fname.main_menu_conf
            );
                
            sprintf(text,
    "Client: Memory reload: Image set referances from `%s'...",
                fname.isr
            );
            MesgAdd(text, xsw_color.standard_text);
            ISRefLoadFromFile(fname.isr);

            sprintf(text,
    "Client: Memory reload: Object create script names from: `%s'...",
                fname.ocsn
            );
            MesgAdd(text, xsw_color.standard_text);
            OCSLoadFromFile(fname.ocsn);

            sprintf(text,
    "Client: Memory reload: Sound scheme from: `%s'...",
                fname.sound_scheme
            );
            MesgAdd(text, xsw_color.standard_text);
            SSLoadFromFile(fname.sound_scheme);

            sprintf(text,
    "Client: Memory reload: Completed."
            );
            MesgAdd(text, xsw_color.standard_text);
        }

        /* ********************************************************** */
        /* Refresh objects in memory. */
        else if(!strcasecmp(arg, "refresh"))
        {
            XSWReclaimGlobalMemory(True);
        }


        /* ********************************************************** */
 
        /* Recreate the selected weapon viewscreen label. */
        VSDrawUpdateWeaponLabel(
            &bridge_win.vs_weapon_image,
            bridge_win.vs_weapon_buf
        );
 


        return(0);
}