more crashes caused by shipowner==NULL

This commit is contained in:
Enno Rehling 2007-02-04 13:30:06 +00:00
parent 8d5ee9c811
commit 8c82b2815e
6 changed files with 42 additions and 35 deletions

View File

@ -192,7 +192,7 @@ print_curses(FILE * F, const faction * viewer, const void * obj, typ_t typ)
unit * owner = shipowner(sh); unit * owner = shipowner(sh);
a = sh->attribs; a = sh->attribs;
r = sh->region; r = sh->region;
if(owner != NULL) { if (owner != NULL) {
if (owner->faction == viewer){ if (owner->faction == viewer){
self = 2; self = 2;
} else { /* steht eine person der Partei auf dem Schiff? */ } else { /* steht eine person der Partei auf dem Schiff? */

View File

@ -449,7 +449,7 @@ print_curses(FILE *F, const faction *viewer, const void * obj, typ_t typ, int in
unit * owner = shipowner(sh); unit * owner = shipowner(sh);
a = sh->attribs; a = sh->attribs;
r = sh->region; r = sh->region;
if((owner) != NULL){ if (owner) {
if (owner->faction == viewer){ if (owner->faction == viewer){
self = 2; self = 2;
} else { /* steht eine person der Partei auf dem Schiff? */ } else { /* steht eine person der Partei auf dem Schiff? */

View File

@ -1102,7 +1102,6 @@ mayboard(const unit * u, const ship * sh)
unit *u2 = shipowner(sh); unit *u2 = shipowner(sh);
return (!u2 || ucontact(u2, u) || alliedunit(u2, u->faction, HELP_GUARD)); return (!u2 || ucontact(u2, u) || alliedunit(u2, u->faction, HELP_GUARD));
} }
int int

View File

@ -652,8 +652,10 @@ ship_allowed(const struct ship * sh, const region * r)
if (is_freezing(u)) { if (is_freezing(u)) {
unit * captain = shipowner(sh); unit * captain = shipowner(sh);
ADDMSG(&captain->faction->msgs, msg_message("detectforbidden", if (captain) {
"unit region", u, r)); ADDMSG(&captain->faction->msgs, msg_message("detectforbidden",
"unit region", u, r));
}
return false; return false;
} }

View File

@ -494,36 +494,42 @@ crew_skill(region * r, faction * f, ship * sh, skill_t sk)
static int static int
try_destruction(unit * u, unit * u2, const char *name, int skilldiff) try_destruction(unit * u, unit * u2, const char *name, int skilldiff)
{ {
const char *destruction_success_msg = "%s wurde von %s zerstoert."; const char *destruction_success_msg = "%s wurde von %s zerstoert.";
const char *destruction_failed_msg = "%s konnte %s nicht zerstoeren."; const char *destruction_failed_msg = "%s konnte %s nicht zerstoeren.";
const char *destruction_detected_msg = "%s wurde beim Versuch, %s zu zerstoeren, entdeckt."; const char *destruction_detected_msg = "%s wurde beim Versuch, %s zu zerstoeren, entdeckt.";
const char *detect_failure_msg = "Es wurde versucht, %s zu zerstoeren."; const char *detect_failure_msg = "Es wurde versucht, %s zu zerstoeren.";
const char *object_destroyed_msg = "%s wurde zerstoert."; const char *object_destroyed_msg = "%s wurde zerstoert.";
if (skilldiff == 0) { if (skilldiff == 0) {
/* tell the unit that the attempt failed: */ /* tell the unit that the attempt failed: */
sprintf(buf, destruction_failed_msg, unitname(u), name); sprintf(buf, destruction_failed_msg, unitname(u), name);
addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN); addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN);
/* tell the enemy about the attempt: */ /* tell the enemy about the attempt: */
sprintf(buf, detect_failure_msg, name); if (u2) {
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT); sprintf(buf, detect_failure_msg, name);
return 0; addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
} }
if (skilldiff < 0) { return 0;
/* tell the unit that the attempt was detected: */ }
sprintf(buf, destruction_detected_msg, unitname(u), name); if (skilldiff < 0) {
addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN); /* tell the unit that the attempt was detected: */
/* tell the enemy whodunit: */ sprintf(buf, destruction_detected_msg, unitname(u), name);
sprintf(buf, detect_failure_msg, unitname(u2), unitname(u), name); addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT); /* tell the enemy whodunit: */
return 0; if (u2) {
} sprintf(buf, detect_failure_msg, unitname(u2), unitname(u), name);
/* tell the unit that the attempt succeeded */ addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
sprintf(buf, destruction_success_msg, name, unitname(u)); }
addmessage(0, u->faction, buf, MSG_EVENT, ML_INFO); return 0;
sprintf(buf, object_destroyed_msg, name); }
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT); /* tell the unit that the attempt succeeded */
return 1; /* success */ sprintf(buf, destruction_success_msg, name, unitname(u));
addmessage(0, u->faction, buf, MSG_EVENT, ML_INFO);
if (u2) {
sprintf(buf, object_destroyed_msg, name);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
}
return 1; /* success */
} }
static void static void

View File

@ -164,7 +164,7 @@ verify_owners(boolean bOnce)
} }
if (u->ship) { if (u->ship) {
unit * bo = shipowner(u->ship); unit * bo = shipowner(u->ship);
if (!fval(bo, UFL_OWNER)) { if (bo && !fval(bo, UFL_OWNER)) {
log_error(("[verify_owners] %u ist Besitzer von %s, hat aber UFL_OWNER nicht.\n", unitname(bo), shipname(u->ship))); log_error(("[verify_owners] %u ist Besitzer von %s, hat aber UFL_OWNER nicht.\n", unitname(bo), shipname(u->ship)));
bFail = true; bFail = true;
if (bOnce) break; if (bOnce) break;