[solved]-Need Help Explaining Code S Need Know Variables Used Decision Logic Else Switch Case Branc Q39017457
Need help explaining a code, here’s
what I need to know
- The variables and what they are used for
- decision logic (if, if-else, switch case) and what thebranching is used to do
- functions and how the code is sub-divided into funtions
- formatting and comments – Good? Bad?
- loops – what the loop is used for and why? When does the loopend?
- Custom header files (end in .h) – What does it seem to bedoing?
- Other
Thanks so much!




*This file contains misc functions for dealing with armor *@(#) armor.c 4.14 (Berkeley) 02/05/99 * Rogue: Exploring the Dungeons of Doom * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wischman * All rights reserved. * See the file LICENSE.TXT for full copyright and licensing information. 506 con uno con Noson so von WN #include <curses.h> #include “rogue.h” * wear: * The player wants to wear something, so let him/her put it on. void wear) wear() register THING *obj; register char *sp; if ((obj = get item(“wear”, ARMOR)) == NULL) return; if (cur_armor != NULL) addmsg (“you are already wearing some”); if (!terse) addmsg”. You’ll have to take it off first”); endmsg(); after = FALSE; return; if (obj->o_type != ARMOR) msg(“you can’t wear that”); return; msg (“you can’t wear that”); return; waste_time(); obj->o_flags = ISKNOW; sp = inv_name (obj, TRUE); cur_armor = obj; if (!terse) addmsg (“you are now “); msg (“wearing $5”, sp); * take off: * Get the armor off of the players back 100 101 102 103 104 105 106 107 108 109 void take off) 110 111 112 113 114 register THING *obj; register THING *obj; if ((obj = cur_armor) == NULL) 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 after = FALSE; if (terse) msg (“not wearing armor”); else 127 128 msg (“you aren’t wearing any armor”); return; 129 130 131 132 133 134 if (!dropcheck (cur_armor)) 135 136 137 return; 138 139 cur_armor = NULL; 140 141 if (terse) 142 addmsg (“was”); else addmsg (“you used to be”); 143 144 145 146 147 148 149 150 151 152 153 msg(” wearing $c) $5″, obj->o_packch, inv_name (obj, TRUE)); Show transcribed image text *This file contains misc functions for dealing with armor *@(#) armor.c 4.14 (Berkeley) 02/05/99 * Rogue: Exploring the Dungeons of Doom * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wischman * All rights reserved. * See the file LICENSE.TXT for full copyright and licensing information. 506 con uno con Noson so von WN #include #include “rogue.h” * wear: * The player wants to wear something, so let him/her put it on. void wear)
wear() register THING *obj; register char *sp; if ((obj = get item(“wear”, ARMOR)) == NULL) return; if (cur_armor != NULL) addmsg (“you are already wearing some”); if (!terse) addmsg”. You’ll have to take it off first”); endmsg(); after = FALSE; return; if (obj->o_type != ARMOR) msg(“you can’t wear that”); return;
msg (“you can’t wear that”); return; waste_time(); obj->o_flags = ISKNOW; sp = inv_name (obj, TRUE); cur_armor = obj; if (!terse) addmsg (“you are now “); msg (“wearing $5”, sp); * take off: * Get the armor off of the players back 100 101 102 103 104 105 106 107 108 109 void take off) 110 111 112 113 114 register THING *obj;
register THING *obj; if ((obj = cur_armor) == NULL) 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 after = FALSE; if (terse) msg (“not wearing armor”); else 127 128 msg (“you aren’t wearing any armor”); return; 129 130 131 132 133 134 if (!dropcheck (cur_armor)) 135 136 137 return; 138 139 cur_armor = NULL; 140 141 if (terse) 142 addmsg (“was”); else addmsg (“you used to be”); 143 144 145 146 147 148 149 150 151 152 153 msg(” wearing $c) $5″, obj->o_packch, inv_name (obj, TRUE));
Expert Answer
Answer to Need help explaining a code, here’s what I need to know The variables and what they are used for decision logic (if, if-… . . .
OR

