Car battery not charging?

There are two bugs:

  1. It checks that the car, specifically the “center” of the car, is in sunlight instead of the individual solar panels.
  2. The method it uses to check whether a tile is inside or outside factors in whether there’s a vehicle roof in the same tile.

Pretty sure the fix is the following: (compiles, but I can’t test it at the moment) (This also scales charge rate with light level instead of it being only on in full sunlight.)

index c5c912e..e9a97cf 100644
--- a/vehicle.cpp
+++ b/vehicle.cpp
@@ -923,9 +923,16 @@ int vehicle::total_power (bool fueled)
 int vehicle::solar_power ()
 {
     int pwr = 0;
-    for (int p = 0; p < parts.size(); p++)
-        if (part_flag(p, vpf_solar_panel) && parts[p].hp > 0)
-            pwr += part_power(p);
+    for (int p = 0; p < parts.size(); p++) {
+        if (part_flag(p, vpf_solar_panel) && parts[p].hp > 0) {
+            int part_x = global_x() + parts[p].precalc_dx[0];
+            int part_y = global_y() + parts[p].precalc_dy[0];
+            // Can't use g->in_sunlight() because it factors in vehicle roofs.
+            if( !g->m.has_flag_ter_or_furn( indoors, part_x, part_y ) ) {
+                pwr += (part_power(p) * g->natural_light_level()) / DAYLIGHT_LEVEL;
+            }
+        }
+    }
     return pwr;
 }
 
@@ -1770,14 +1777,7 @@ void vehicle::gain_moves (int mp)
             thrust (cruise_velocity > velocity? 1 : -1);
     }
 
-    if (g->is_in_sunlight(global_x(), global_y())) {
-      refill (AT_BATT, solar_power());
-    }
-
-    // If the vehicle is moving, trickle-charge storage batteries.
-    if (velocity && one_in(10)) {
-      refill (AT_BATT, abs(velocity) / 100);
-    }
+    refill (AT_BATT, solar_power());
 
     // check for smoking parts
     for (int ep = 0; ep < external_parts.size(); ep++)

That code sounds like an explanation of nuclear physics to me :slight_smile: But yea, I had roofs everywhere… I don’t have any picture, so I’ll try to ascii draw it:

        .).
      ..---..
    ----^----         I hope it gets screwed with text formating.
    0|"""|0
    +SoS+     - controls are at left seat S
  0#BHo#0    - B is bed
  0#HHH#0    - H's and o's inside are all roofed space, seats and bed too
  0#HHH#0
  0#HHH#0
  0#&+-#0
   0H=H0
     H=H

I had solar panels on all outside boards.

Seriously, I can’t draw in ascii. So, it means that if you have non-roofed tile in the middle of your vehicle, then batteries should charge?

The “center”, or more technically the origin of your vehicle is whichever tile was put down first. That’s often, but not always the driver’s seat of the vehicle. Of course, if it’s anywhere near the center of the vehicle, then the two bugs conspire to deactivate all your solar panels. Anyway, the above should fix it, so it should appear in nightlies within a day or two.

Cool… I’ll be finally able to cook that damn food in kitchen unit for free…

I just wanna know this much:
If you set something on fire, like a spire or a house, and you exit that map square - on the next day, the fire is still there regardless the weather… such is the game mechanix.
If I acquire a solar-powered car and park it near my base, further spend some days exploring the vicinity in some combustion-driven machine and come back to check the first car’s battery, the gauge is stuck to zero.
But then, if I scrap some frames, put a regular, not big (nevermind, a detail really) electric motor on it with two storage batteries and four panels - the tank is full in a matter of days, in fine weather that is.
Are the “starter” clean-power cars ment to be that way?

[quote=“vultures, post:25, topic:2083”]But then, if I scrap some frames, put a regular, not big (nevermind, a detail really) electric motor on it with two storage batteries and four panels - the tank is full in a matter of days, in fine weather that is.
Are the “starter” clean-power cars ment to be that way?[/quote]
I literally run 1:1 battery vs solar panels, and my car never runs out of charge (usually doesn’t dip below 90%). I used to install like 6-8 of each, now I’m only using 4 of each, or six, I can’t remember, and have never had a problem. I only use one engine and rarely go driving all day, so if you have two engines and drive longer or drive at unsafe speeds, you’ll probably drain more.